[翻译] Effective C++, 3rd Edition, Chapter 4. Designs(设计)和 Declarations(声明)

Chapter 4. Designs(设计)和 Declarations(声明)

作者:Scott Meyers

译者:fatalerror99 (iTePub's Nirvana)

发布:http://blog.csdn.net/fatalerror99/

软件设计——使软件能做你想让它做的事情的途径——典型情况下,从一个相当概括的想法开始,但是最终它们会变得详细,详细到足以进行具体的 interfaces(接口)的开发。这些 interfaces(接口)很可能在随后被转化为 C++ declarations(声明)。在本章,我们触及设计和声明优良的 C++ interfaces(接口)的问题。我们以或许是设计各种 interfaces(接口)的最重要的指导方针开始:它们应该易于正确使用,而难以错误使用。这也为许多从范围广阔的主题中选择的更特殊的指导方针设置了舞台,包括 correctness(正确性),efficiency(效率),encapsulation(封装),maintainability(可维护性),extensibility(可扩展性),以及 conformance to convention(顺应惯例)。

后面的素材并不是你需要知道的关于好的 interface(接口)设计的全部内容,而是采集了一些最重要的注意事项,一些最容易发生的错误的警告,并为 class(类),function(函数)和 template(模板)的设计者经常遇到问题给出了解决方案。

本章包括以下内容,点击打开:

Item 18: Make interfaces easy to use correctly and hard to use incorrectly

Item 19: Treat class design as type design

Item 20: Prefer pass-by-reference-to-const to pass-by-value

Item 21: Don't try to return a reference when you must return an object

Item 22: Declare data members private

Item 23: Prefer non-member non-friend functions to member functions

Item 24: Declare non-member functions when type conversions should apply to all parameters

Item 25: Consider support for a non-throwing swap

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值