Classes(2)

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

Constructors
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.

Python2.7:测试内部类型及type和isinstance用法区别

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

WEB-INFclasses为空(未编译)的解决办法

今天重新从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的十个使用技巧

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

项目中的java文件没有在WEB-INF\classes中生成class文件

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文件为空

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

将 src中的资源文件自动生成到/web-inf/classes/目录下

http://www.cnblogs.com/xfiver/archive/2010/07/07/1772764.html Eclipse下无法自动编译,或者WEB-INF/classes目录下没文...
  • snioper007
  • snioper007
  • 2013年07月29日 09:52
  • 4687

MyEclipse6.0编译后的类无法自动发不到WebRoot/WEB-INF/classes文件夹下(转)

今天,碰到个怪事,在myeclipse中新建一个项目之后,结果保存之后,再查看WEB-INF/classes/,竟然里面是空的,而output路径也设的好好的啊,怪了,于是google了一下,发现有此...
  • cawonlu
  • cawonlu
  • 2014年11月13日 09:45
  • 858

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

今天发布某个Web项目新版本,需要替换服务器上的几个class文件。在项目树中找到WEB-INF/classes目录,竟然发现没有任何class文件!...
  • yzhuahq
  • yzhuahq
  • 2016年04月21日 11:46
  • 13720
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Classes(2)
举报原因:
原因补充:

(最多只允许输入30个字)