您的位置:首页 > 编程语言 > C语言/C++

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

2006-01-22 21:30 513 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐