摘要: The improved version is simply the following: 根据生日来判断是否是婴儿潮时期出生的,isBabyBoomer()是一个糟糕的设计,每次调用这个方法都会创建Calendar,TimeZone以及2个Date对象实例,当此方法被频繁调用时将会非常地影响性能。 阅读全文
posted @ 2017-05-27 17:49 FrankYou 阅读(248) 评论(0) 推荐(0)
摘要: 如果你定义的类仅仅是包含了一些静态的方法和静态的字段,这些类一般是一些工具类,这些一般是设计为不能被实例化的。 1. Attempting to enforce noninstantiability by making a class abstract does not work. 2. a cla 阅读全文
posted @ 2017-05-27 16:54 FrankYou 阅读(638) 评论(0) 推荐(0)
摘要: 1. 通过一个公开的字段来获取单例 The main advantage of the public field approach is that the declarations make it clear that the class is a singleton: the public sta 阅读全文
posted @ 2017-05-27 15:57 FrankYou 阅读(403) 评论(0) 推荐(0)
摘要: the Builder pattern is a good choice when designing classes whose constructors or static factories would have more than a handful of parameters. 阅读全文
posted @ 2017-05-27 15:14 FrankYou 阅读(191) 评论(0) 推荐(0)