TCPL中的建议
来源:互联网 发布:自己室内设计软件 编辑:程序博客网 时间:2024/05/26 09:54
Chapter 1
[1] When you program, you create a concrete representation of the ideas in your solution to some problem. Let the structure of the program reflect those ideas as directly as possible:
[a] If you can think of ‘‘it’’ as a separate idea, make it a class.
[b] If you can think of ‘‘it’’ as a separate entity, make it an object of some class.
[c] If two classes have a common interface, make that interface an abstract class.
[d] If the implementations of two classes have something significant in common, make that commonality a base class.
[e] If a class is a container of objects, make it a template.
[f] If a function implements an algorithm for a container, make it a template function implementing the algorithm for a family of containers.
[g] If a set of classes, templates, etc., are logically related, place them in a common namespace.
[2] When you define either a class that does not implement either a mathematical entity like a matrix or a complex number or a low-level type such as a linked list:
[a] Don’t use global data (use members).
[b] Don’t use global functions.
[c] Don’t use public data members.
[d] Don’t use friends, except to avoid [a] or [c].
[e] Don’t put a ‘‘type field’’ in a class; use virtual functions.
[f] Don’t use inline functions, except as a significant optimization.
- TCPL中的建议
- K&R TCPL 附录B中<time.h>中的函数的相关
- 《Effective Java》中的建议
- TCPL读书笔记(1)
- TCPL学习笔记
- TCPL 的学习
- tcpl 阅读笔记 1
- TCPL 阅读笔记 2
- tcpl 阅读笔记 3
- tcpl 阅读笔记 4
- tcpl 阅读笔记 5
- tcpl 阅读笔记 6
- tcpl 阅读笔记 7
- tcpl 阅读笔记 8
- TCPL习题答案6.6
- <TCPL>习题答案6.
- TCPL 阅读笔记 Chapter1
- TCPL C++资源管理简述
- Oracle中SQL语句注意事项
- ERP human resources: The key to seccuss
- 存储过程与Insert哪个更快
- 删除注释
- hibernate通用方法
- TCPL中的建议
- 几个预编译指令的用法
- Hibernate学习笔记:混合使用每个继承结构一张表 和 每个子类一张表
- sprintf 用法 注意事项
- 读取xml通过deserialize和linq to sql快速更新数据表
- java运行时多态性的实现
- Oracle load sqlldr details
- CSS 黑色 横向三级菜单
- java定时器的使用(Scheduler )