06 2011 档案

摘要:生成数据 (function(){ Components.utils.import("resource://gre/modules/AddonManager.jsm"); AddonManager.getAllAddons(function(addons){ var rslt = {}; for each(var addon in addons){... 阅读全文
posted @ 2011-06-16 08:01 倚楼无语F5 阅读(277) 评论(0) 推荐(0) 编辑
摘要:Defines an interface for creating an object,but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclassesProvide an interface for creating families of related or dependent objects without specifying their concrete classes两个模式非常类似,那它们之间什么区别呢?先总结下工 阅读全文
posted @ 2011-06-13 13:40 倚楼无语F5 阅读(171) 评论(0) 推荐(0) 编辑
摘要:工厂方法模式定义Defines an interface for creating an object,but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses一般java创建一个实例是这样Productp=newProduct();可以实际情况要复杂。创建一个实例需要非常多的初始化工作。诸如:intdata[]=[1,2,3];Productp=newProduct(data);为了复用,我们就用一个类Factory把数 阅读全文
posted @ 2011-06-12 21:23 倚楼无语F5 阅读(171) 评论(0) 推荐(0) 编辑
摘要:适配器模式定义(个人理解:只是个套子)Convert the interface of a class into another interface clients excpet. Adapter lets classes work together that couldn't otherwise becase of incompatible interfaces.模式理解:看到第一眼的时候,我就觉得坑爹啊,怎么又和bridge长的那么像啊。再一转念,其实它们之间有巨大的不同:从实际编码来说Adaptee基本上就是现成的,而Target也很高概率是完成的。而Adpater目的是为了让T 阅读全文
posted @ 2011-06-12 15:10 倚楼无语F5 阅读(209) 评论(0) 推荐(0) 编辑
摘要:个人觉得策略、桥接、命令这三种模式有一定的相似度。所以放在一些,写点东西,理理思路。策略模式的定义(个人理解:单边变化)Defines a family of algorithms, encapsulate each one, and make them inter changeable .Strategy lets the algorithm vary independently from clients that use it理解:这种模式很常见,通常大家也都会把一部分可能有变化或者就是需要有多少变化的操作(步骤)通过接口给分离出去,自身只要有一个实现该接口的成员即可。这种就是松耦合,有人 阅读全文
posted @ 2011-06-12 10:36 倚楼无语F5 阅读(357) 评论(0) 推荐(0) 编辑