工厂模式,实例化对象,用工厂方法取代new操作。工厂模式基本与简单工厂模式差点儿相同,简单工厂中每次加入一个子类必须在工厂类中加入一个推断分支,这违背了开闭原则。而工厂模式的解决方法是将简单工厂中的每一个推断都生成一个工厂子类,工厂子类位于工厂类抽象和产品类实现之间,实际依旧属于实现。工厂类中的为抽...
分类:
编程语言 时间:
2015-01-17 09:58:20
阅读次数:
220
1)控制反转(IOC):以前传统的java开发模式中,当需要一个对象时我们,我们会自己使用new或者getInstance等直接或者间接调用构造方法创建一个对象,而在Spring开发模式中,Spring容器使用了工厂模式为我们创建了所需要的对象,我们使用时不需要自己去创建,直接调用Spring为我们提供的对象即可,这就是控制反转的思想。实例化一个java对象有三种方式:使用类构造器,使用静态工厂方法,使用实例工厂方法,当使用spring时我们就不需要关心通过何种方式实例化一个对象,spring通过控制反转机...
分类:
编程语言 时间:
2015-01-16 23:51:31
阅读次数:
604
一篇非常精彩的解释CAP理论的文章,翻译水平有限,不准确之处请参考原文,还请见谅。 Chapter 1: “Remembrance Inc” Your new venture :Last night when your spouse appreciated you on remembering her birthday and bringing her a gift, a strange Idea...
分类:
其他好文 时间:
2015-01-16 22:24:39
阅读次数:
321
在使用new和delete要注意的事项,以及使用智能指针时要注意的事项。...
分类:
编程语言 时间:
2015-01-16 22:23:45
阅读次数:
181
//用索引取一个记录中的各项using system;class IndexerRecord{private string[] data= new string [6];private string[] keys = { "Author","Publisher","Title", "Subje...
题目:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space fo...
分类:
编程语言 时间:
2015-01-16 22:14:33
阅读次数:
223
题目:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't ...
分类:
编程语言 时间:
2015-01-16 22:14:22
阅读次数:
257
基本查询方式 字符串条件查询, 索引数组条件查询 对象条件查询 SQL语句大小写是一样的,但是,执行的时候有一个小写到大写的转换,所以最好写大写$condition=new \stdClass();//对象形式查询stdClass是php内置类,可以理解为一个空类,这里要把条件作为字段保存到其中,而...
分类:
数据库 时间:
2015-01-16 20:40:54
阅读次数:
266
在Activity中,注册广播的一个Demo。总共分3步第一步:定义一个BroadcastReceiver广播接收类:private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver(){ @Override ...
分类:
移动开发 时间:
2015-01-16 20:32:34
阅读次数:
149
代码: protected string FormatUrlEncode(string url) { string result = string.Empty; if (url.IndexOf("?") list = new List()...
分类:
Web程序 时间:
2015-01-16 19:00:10
阅读次数:
173