原创 2004年09月20日 23:19:00

1. Initialize all member data in all constructors, if possible.
2. Initialize data members in the order in which they're declared.
3. Enfore the singleton property by using a a private constructor(It seems like the Singleton pattern in GoF)
4. Enforce the singleton property by using all static member data and reference counting.
5. Prefer deep copies to shallow copies until proven otherwise.
A deep copy of an object is a member-wise copy of the object's member data. A shallow copy typically just points to or refer to a single reference copy.

Reason to Create a Class
1. Model real-world objects
2. Model abstract objects--an object that isn't a concrete, real-world object, but that privides an abstraction of other concrete objects. A good example is the classic Shape object.
3. Reduce complexity. 
Create a class to hide information so that you won't need to think about it.
4. Isolate complexity.
5. Hide implementation details.
6. Limit effects of chagnes.
Isolate areas that are likely to chagne so that the effects of changes are limited to the scope of a sinlge or, at most a few classes.
7. Hide global data.
8. Streamline parameter passing.
If you're passing a parameter among several routines, that might indicate a need to factor those routines into a class that share the parameter as class data.
9. Make central points of control.
It's a good idea to control each task in one place.
10. Facilitate reusable code.
11. Plan for a family of programs.
Seems just like the item 6.
12. Package related operations.
In case in which you can't hide information, share data, or plan for flexibility, you can still package sets of operations into sensible groups such as statistcal functions, string-manipulation routines and so on.
13. To accomplish a specific refactoring.

Classes to Avoid
1. Avoid creating god classes.
2. Eliminate irrelevant classes.
If a class consists only of data but no behavior, ask yourself whether it's really a class.
3. Avoid classes named after verbs.
A class that only behavior but no data is generally not really a class.


# -*- coding: UTF-8 -*-class test1: passclass test2(test1): passif __name__=="__main__": #判断类型 a=123...
  • LANGZI7758521
  • LANGZI7758521
  • 2016年03月24日 14:15
  • 2275


今天重新从SVN将项目迁出了一下,在用Myeclipse部署项目时,发现WEB-INF\classes是空的  根据网上说的试了下,不行,  1. 确保 project->build automat...
  • zhanglang2
  • zhanglang2
  • 2015年04月29日 14:47
  • 1336

104. Spring Boot 启动流程分析第三篇【从零开始学Spring Boot】

问题的提出:Spring Boot不像spring需要定义xml文件文件,那么spring boot是如何在没有配置文件的情况下为我们启动一个完整的WEB工程的呢。我们先@SpringBootAppl...
  • gebitan505
  • gebitan505
  • 2017年02月13日 13:31
  • 1113


 ExecutorService这个接口从Java 5开始就已经存在了。这得追溯到2004年了。这里小小地提醒一下,官方已经不再支持Java 5, Java 6了,Java 7在半年后也将停止支...
  • idaretobe
  • idaretobe
  • 2015年03月23日 22:13
  • 421


1.首先确定project->Build Automatically是否勾选上: 2.然后,再进行测试,能不能进行编译,如果还是不能,则进行手动编译: project->clean 3.进入cl...
  • u011008029
  • u011008029
  • 2015年10月21日 14:08
  • 10682

java 异常处理

try   }finally{
  • doctor_who2004
  • doctor_who2004
  • 2014年10月02日 16:57
  • 1543

Tomcat报错: /项目名/WEB-INF/classes文件为空

转自: 一般启动时说找不到该类: Tomcat 6.0/webapps/项目名/WEB...
  • jim_007
  • jim_007
  • 2017年03月10日 13:23
  • 880

将 src中的资源文件自动生成到/web-inf/classes/目录下 Eclipse下无法自动编译,或者WEB-INF/classes目录下没文...
  • snioper007
  • snioper007
  • 2013年07月29日 09:52
  • 4687


  • cawonlu
  • cawonlu
  • 2014年11月13日 09:45
  • 858

Eclipse 项目无法自动编译,WEB-INF/classes目录下没有class文件的解决过程

  • yzhuahq
  • yzhuahq
  • 2016年04月21日 11:46
  • 13720