最新文章列表

并发工具优先于wait和notify

ssseeeee
Zhang_Kai_123 评论(0) 有588人浏览 2014-09-18 20:57

Java SE: Effective Java Notes "Concurrency"

Use the Advanced Concurrent Tools instead of the legacy wait() and notify(). Java Advanced Concurrent Tools:     1> Executor Framework: ExecutorService, Callable, Executors ...     2> Concur ...
DavyJones2010 评论(0) 有579人浏览 2014-09-12 15:33

Java SE: Effective Java Notes "Methods"

Effective Java 2nd Edition, Chapter 7, Item 42 Be careful when using var args. Do not abuse var args in our custmoized methods. 1) Painful Arrays.asList for Primitive Types package edu.xmu.guava.co ...
DavyJones2010 评论(0) 有743人浏览 2014-08-28 19:35

Effective Java notes-Creating and Destroying Objects(1)

Item 1 Consider static factory method instead of constructors   Advantages: One advantage of static factory methods is that, unlike constructors, they have names. (Mostly used in Java.utils.Colle ...
why_wjf 评论(0) 有683人浏览 2014-03-19 14:11

ActiveMQ 源码学习 2:从 CommandTypes 谈常量接口反模式

在上一篇文章里,我写了在阅读 ActiveMQ 的一小段源码时碰到的两种设计模式:抽象工厂和策略模式。实际上 ActiveMQ 源码量很大,只要认真分析,你会找到很多设计模式的应用场景。其中,有一个模式非常典型,并且它在整个 ActiveMQ 的源码架构中扮演者非常重要的角色,它就是 GoF 设计模式中的:命令模式(Command Pattern)。Command 是 ActiveMQ brok ...
wxl24life 评论(2) 有1500人浏览 2013-08-15 23:43

服务提供者框架 《Effective Java 一》

引入:静态工厂方法返回的对象所属的类,在编写包含该静态工厂方法的类时可以并不存在,这种灵活的静态工厂方法构成了服务提供者框架的基础。— ...
aine_pan 评论(0) 有931人浏览 2013-07-15 22:35

Item 19: Use interfaces only to define types

1.  Interfaces should be used only to define types. They should not be used to export constants.   2.  The constant interface pattern is a poor use of interfaces. That a class uses some constants i ...
leonzhx 评论(0) 有967人浏览 2013-04-18 18:00

Item 18: Prefer interfaces to abstract classes

1.  Existing classes can be easily retrofitted to implement a new interface.   2.  Interfaces are ideal for defining mixins.   3.  A mixin is a type that a class can implement in addition to its ...
leonzhx 评论(0) 有1069人浏览 2013-04-12 20:14

第1条: 考虑用静态工厂方法替代构造器

1 考虑用静态工厂方法替代构造器 类可以提供一个公有的静态工厂方法,他只是一个返回类的实例的静态方法。 实例受控类 public static Boolean valueOf(boolean b) { return b ? Boolean.TRUE : Boolean.FALSE; } 编写实例受控类有几个原因。实例受控使得类可以确保他是一个Singleton或者是不可实例化的。他 ...
flyvszhb 评论(0) 有737人浏览 2013-03-26 15:42

Item 17: Design and document for inheritance or else prohibit it

1.  The class must document precisely the effects of overriding any method. In other words, the class must document its self-use of overridable methods.   2.  By convention, a method that invokes o ...
leonzhx 评论(0) 有1675人浏览 2013-03-10 22:52

Item 16: Favor composition over inheritance

1.  Inheriting from ordinary concrete classes across package boundaries is dangerous.   2.  Unlike method invocation, inheritance violates encapsulation. The superclass’s implementation may change ...
leonzhx 评论(0) 有990人浏览 2013-03-04 17:12

Item 15: Minimize mutability

1.  The Java platform libraries contain many immutable classes, including String, the boxed primitive classes, and BigInteger and BigDecimal.   2.  Immutable classes are easier to design, implement ...
leonzhx 评论(0) 有1015人浏览 2013-03-01 16:11

Item 14: In public classes, use accessor methods, not public fields

1.  If a class is accessible outside its package, provide accessor methods to preserve the flexibility to change the class’s internal representation.   2.  If a class is package-private or is a pri ...
leonzhx 评论(0) 有1191人浏览 2013-02-26 22:07

Item 13: Minimize the accessibility of classes and members

1.  A well-designed module hides all of its implementation details, cleanly separating its API from its implementation. Modules then communicate only through their APIs and are oblivious to each othe ...
leonzhx 评论(0) 有1048人浏览 2013-02-25 20:49

Item 12: Consider implementing Comparable

1.  compareTo is the sole method in the Comparable interface. By implementing Comparable, a class indicates that its instances have a natural ordering.   2.  By implementing Comparable, you allow y ...
leonzhx 评论(0) 有1118人浏览 2013-02-22 21:26

Item 11: Override clone judiciously

1.  The Cloneable interface was intended as a mixin interface for objects to advertise that they permit cloning. However it lacks a clone method, and Object’s clone method is protected.   2.  If a c ...
leonzhx 评论(0) 有1389人浏览 2013-02-21 22:15

Item 10: Always override toString

1.    The string returned by Object.toString consists of the class name followed by an “at” sign (@) and the unsigned hexadecimal representation of the hash code. 2.    Providing a good toString imp ...
leonzhx 评论(0) 有1024人浏览 2013-02-20 10:44

Item 8: Obey the general contract when overriding equals

1. A value class is simply a class that represents a value, such as Integer or Date. A programmer who compares references to value objects using the equals method expects to find out whether they are ...
leonzhx 评论(0) 有1010人浏览 2013-02-12 11:07

Item 6: Eliminate obsolete object references

1.  An obsolete reference is simply a reference that will never be dereferenced again.   2.  Memory leaks in garbage-collected languages (more properly known as unintentional object retentions) are ...
leonzhx 评论(0) 有1105人浏览 2013-02-08 09:25

最近博客热门TAG

Java(141744) C(73651) C++(68608) SQL(64571) C#(59609) XML(59133) HTML(59043) JavaScript(54919) .net(54785) Web(54514) 工作(54118) Linux(50905) Oracle(49875) 应用服务器(43289) Spring(40812) 编程(39454) Windows(39381) JSP(37542) MySQL(37267) 数据结构(36424)

博客人气排行榜

    博客电子书下载排行

      >>浏览更多下载

      相关资讯

      相关讨论

      Global site tag (gtag.js) - Google Analytics