在设计供多个 C++ 使用的类时,我应该使用 API/ABC 吗?

发布于 2024-09-11 05:55:46 字数 1432 浏览 4 评论 0原文

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

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

发布评论

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

评论(2

余生一个溪 2024-09-18 05:55:46

您确定所有这些函数都属于同一个 X 类吗?考虑将不同的功能分成不同的类:
http://en.wikipedia.org/wiki/Low-Coupling_/_High- Cohesion_pattern

但是如果不知道 X 的功能是什么,就很难提供进一步的帮助。

Are you sure all these functions belong to the same class X? Think about separating different functionality into different classes:
http://en.wikipedia.org/wiki/Low-Coupling_/_High-Cohesion_pattern

But without knowing what the functions of X are it is difficult to help further.

烧了回忆取暖 2024-09-18 05:55:46

如果事情不太可能改变,那么可能不值得付出额外的努力。

但是,如果您决定这样做,问题是新类是否会实现全部功能或仅实现部分功能。例如,它们是否共享后端存储,因此所有内容都需要立即更新(在这种情况下,拆分没有意义),或者它们是否涉及完全独立的问题,在这种情况下,拆分(如 @GarethOwen 所建议的)是可能是要走的路。

If things are unlikely to change then it's probably not worth the extra effort.

If you decide to, though, the question is whether new classes would implement all or just part of the functionality. For example, do they share backend storage, so all would need to be updated at once (in which case there is no point in splitting), or do they relate to entirely separate concerns in which case splitting (as suggested by @GarethOwen) is probably the way to go.

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