实践中最常见的抽象接口类型是什么

发布于 2024-09-10 13:57:24 字数 220 浏览 4 评论 0原文

我不完全确定如何在标题中表达我想问的内容,因此我将在接下来的内容中尝试更好地澄清它。

对于 C++ 软件库开发人员,您发现自己经常在项目/工作之间重写哪些抽象接口?例如,我认为对于不同的项目来说,为“打印”对象编写抽象接口并根据该项目的要求序列化对象是相当常见的做法(即使它们是根据其他已建立的库来实现的,这些库提供了很多这样的功能)。您对此有什么经验?

如果问题太模糊,请随时建议如何澄清它。

I wasn't completely sure how to phrase what I wanted to ask in the title so I'll try to clarify it better in what follows.

For C++ software library developers, what abstract interfaces do you find yourselves rewriting often between projects/jobs? For instance, I would imagine that it is fairly common practice for different projects to write abstract interfaces for "printing" objects and for serializing objects based on the requirements of that project (even if they are implemented in terms of other established libraries which provide a lot of that functionality). What are your experiences with this?

If the question is too vague feel free to recommend how to clarify it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紫南 2024-09-17 13:57:25

我不知道这个问题是否是c++特定的。似乎是一个一般性的编程问题。我发现即使我做 JS 编码时我仍然使用抽象概念。

我认为最简单的答案是,只要对不同类型执行同一组操作,就可以使用抽象类。抽象方法填充该特定实现的细节,其他方法提供框架,即“同一组操作”。

作为一名java开发人员,使用抽象模式进行DAO CRUD操作是很常见的。它总是一样的,唯一不同的是类型......

I don't know if the question is c++ specific. Seems like a general programming question. I find even when I do JS coding I still use the abstract concept.

I think the simplest answer is you use abstract classes whenever you do the same set of operations on different types. The abstract methods fill in the details of that particular implementation, the other methods provide the framework, i.e. the "same set of operations".

As a java developer, it is very common to use the abstract pattern for DAO CRUD operations. Its always the same, the only thing different is the type...

碍人泪离人颜 2024-09-17 13:57:24

这取决于您在某些情况下正在开发的内容。这里有一个简短的列表:

克隆、创建(工厂方法)、序列化、线程、中介、观察。

it depends on what you're developing in some cases. here's a short list:

clone, create (factory method), serialization, threading, mediation, observing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文