前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C++核心准则​A.1-A.4:架构理念

C++核心准则​A.1-A.4:架构理念

作者头像
面向对象思考
发布2020-11-03 15:03:34
3000
发布2020-11-03 15:03:34
举报

A.1: Separate stable code from less stable code

A.1:将稳定代码与不稳定代码分开

Isolating less stable code facilitates its unit testing, interface improvement, refactoring, and eventual deprecation.

隔离不稳定的代码有助于其单元测试,接口改进,重构乃至最终弃用。

A.2: Express potentially reusable parts as a library

A.2:将潜在可重用的部件表示为库

Reason(原因)

Note(注意)

A library is a collection of declarations and definitions maintained, documented, and shipped together. A library could be a set of headers (a "header-only library") or a set of headers plus a set of object files. You can statically or dynamically link a library into a program, or you can #include a header-only library.

库是放在一起维护,记录和发布的声明和定义的集合。一个库可以是一组头文件(“仅头文件的库”)或一组头文件外加一组目标文件。您可以将库静态或动态链接到程序,也可以#include仅包含文件的库。

A.4: There should be no cycles among libraries

A.4:库之间不应存在引用循环

Reason(原因)

  • A cycle complicates the build process.
  • 循环引用会使编译过程复杂化。
  • Cycles are hard to understand and might introduce indeterminism (unspecified behavior).
  • 循环很难理解,并且可能引入不确定性(未指定的行为)。

Note(注意)

A library can contain cyclic references in the definition of its components. For example:

库在其组件的定义中可以包含循环引用。例如

代码语言:javascript
复制
???

However, a library should not depend on another that depends on it.

然而,一个库不应该依赖于另一个依赖它的库。

原文链接

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#a-architectural-ideas

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-10-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 面向对象思考 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • A.1: Separate stable code from less stable code
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档