上一页 1 ··· 3 4 5 6 7
摘要: 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) 编辑
摘要: 最近做点小东西,用到ID3标签。所以做个笔记备忘和整理。那么ID3是什么?藏在MP3头部或者尾部用来描述歌曲的信息。主流的写法有两种:ID3v1,ID3v2.3ID3v1是把128位的字段信息藏在尾部。长度固定。字段不满规定长度的用0填充。ID3v2.3 是把信息藏在头部。长度可变。做法是:标签头+若干连续的标签帧, 其中标签头指出所有标签帧的长度。标签帧分成帧头和帧体,其中帧头会指出帧体的长度。参考http://www.id3.org/id3v2.3.0#head-42b02d20fb8bf48e38ec5415e34909945dd849dc 阅读全文
posted @ 2011-04-16 17:46 倚楼无语F5 阅读(756) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7