Java??????????
???????????? ???????[ 2017/1/11 9:47:04 ] ??????????????????? Java
????????????????????????????????С????????????????????????java?????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????
????1.???????Open Close Principle)
??????????????????????????????????????????????????????????????е?????????????ε?Ч??????????仰?????????????????????????????????????????????????Ч?????????????y????????
????2.??????????Dependence Inversion Principle??
??????????????????????????????????????????????????????????塣
????3.?????????Interface Segregation Principle??
???????????????????????????????????????????????????????????
????4.???????????????????Demeter Principle??
?????????????????????????????????????????????????????????????
????5.?????????Composite Reuse Principle??
??????????????ú??/????????????????ü?С?
????java????????????
????1??????????????Factory Method??
????????????????????????????????????????????Щ??????????????????????????????????????????????????????????????
????2.????????Singleton??
????????????Singleton????????????????????Java????У??????????????????JVM?У?????????????????????????????м????????
????1???Щ?????????????????Щ??????????????????????????
????2??????new???????????????????????????????GC?????
????3????Щ???罻???????????????棬?????????????????????????????????????????????????????????????????????????????????????????????????
????4.??????????????????????????????????
???????????????£?
???? public class Singleton {
????/* ??????о????????????????????????null???????????????? */
????private static Singleton instance = null;
????/* ??й????????????????? */
????private Singleton() {
????}
????/* ??????????????????? */
????public static Singleton getInstance() {
????if (instance == null) {
????instance = new Singleton();
????}
????return instance;
????}
????/* ???????????????л??????????????????л????????? */
????public Object readResolve() {
????return instance;
????}
????}
????
????3.????????Proxy??
?????????????????????????????????????????????????????????????????Щ??????
??????????????ó?????
??????????е????????????????????е???????и????????????????
????1???????е???????????????Υ????“?????????????????”?????
????2?????????????????????е???????????????????п????????????????????
??????????????????????????????????????????????????
???????????£?
????public interface Sourceable {
????public void method();
????}
????public class Source implements Sourceable {
????@Override
????public void method() {
????System.out.println("the original method!");
????}
????}
????public class Proxy implements Sourceable {
????private Source source;
????public Proxy(){
????super();
????this.source = new Source();
????}
????@Override
????public void method() {
????before();
????source.method();
????atfer();
????}
????private void atfer() {
????System.out.println("after proxy!");
????}
????private void before() {
????System.out.println("before proxy!");
????}
????}
????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11