未完 java设计: naming convention | 命名规范
应该遵循的规范:
类/接口/属性名,使用名词或形容词;
方法名使用动词。
Java Naming Conventions:
http://www.oracle.com/technetwork/java/codeconventions-135099.html
Ixxx、Service、servieimpl、dao、daoimpl,真的有必要吗?
Naming the Java Implementation Classes:
http://isagoksu.com/2009/development/java/naming-the-java-implementation-classes/
http://stackoverflow.com/questions/2814805/java-interfaces-implementation-naming-convention
对象的 State & Behavior:
state is stored in fields and behavior is shown via methods
对象的属性及其对应的值构成对象的状态:An object's state is defined by the attributes of the object and by the values these have.通俗的讲可以将state理解成对象的属性(字段)。
很多的设计模式中,都遵循“separate state and behavior”的原则。state即字段,behavior即方法,既然要分离出对象的行为(方法)来,而类/接口的名称约定一般为名词,所以,分离出的行为接口的命名,一般也就遵循“动词变名词”的原则,如发送email有个方法叫send,分离出发送行为后,可以将其命名为EmailSender;某类Xxx有个print方法,分离出打印的行为后,可以将其命名为XxxPrinter等;分离出账单类Bill的计算账单方法calculate()后,可以将分离出的"计算账单"这一行为的接口命名为BillCalculator等,诸如此类。