摘要:
迪米特法则(Law of Demeter LoD) –>最少只是原则(Least Knowledge Principle,LKP) 一个对象应该对其它的对象有最少的了解 阅读全文
摘要:
开放关闭原则(Open Close Principle OCP)Software entities like classes,modules and functions should be open for extension but closed for modifications.一个软件实体如类、模块和函数应该对扩展开放,对修改关闭。 阅读全文
摘要:
接口隔离原则Interface Segregation PrincipleClients should not be forced to depend upon interfaces that they don’t use客户端不应该依赖它不需要的接口The dependency of one class to another one should depend on the smallest possible interface类间的依赖关系应该建立在最小的接口上 阅读全文
摘要:
依赖倒置原则(Dependence Inversion Principle) High level modules should not depend upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details.Details should depend upon abstractions. 高层模块不应该依赖低层模块,两者都应该依赖其抽象;抽象不应该依赖细节;细节应该依赖抽象 。 阅读全文
摘要:
里氏替换原则 If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged where o1 is substituted for o2 then S is a subtype of T。(Functions that use pointers or references to base classes must be able to use object of d 阅读全文
摘要:
Single Responsibility Principle应该有且只有一个原因引起类的变更 阅读全文
摘要:
ThreadLocal即线程局部变量。功能:为每个使用该变量的线程,提供一个该变量的副本。其实ThreadLocal中拥有一个Map,它是线程->变量的映射。主要方法有三个,set,get,initValue。set与get的作用不用多讲,主要是initValue,它默认返回的是null,子类可以通过重载该方法,来改变默认值。1publicvoidset(Tvalue){2Threadt=Thread.currentThread();3ThreadLocalMapmap=getMap(t);4if(map!=null)5map.set(this,value);6else7createMa 阅读全文