en

Joshua Bloch

  • diormualıntı yaptı2 yıl önce
    In cases where a class seems to require multiple constructors with the same signature, replace the constructors with static factory methods and carefully chosen names to highlight their differences.
  • diormualıntı yaptıgeçen yıl
    equal objects must have equal hash codes.
  • diormualıntı yaptıgeçen yıl
    well-designed component hides all its implementation details, cleanly separating its API from its implementation. Components then communicate only through their APIs and are oblivious to each others’ inner workings. This concept, known as information hiding or encapsulation
  • diormualıntı yaptıgeçen yıl
    the equality test imposed by the compareTo method should generally return the same results as the equals method
  • diormualıntı yaptıgeçen yıl
    Use of the relational operators < and > in compareTo methods is verbose and error-prone and no longer recommended.
  • diormualıntı yaptıgeçen yıl
    The rule of thumb is simple: make each class or member as inaccessible as possible.
  • diormualıntı yaptıgeçen yıl
    a method overrides a superclass method, it cannot have a more restrictive access level in the subclass than in the superclass
  • diormualıntı yaptıgeçen yıl
    classes with public mutable fields are not generally thread-safe
  • diormualıntı yaptıgeçen yıl
    Note that a nonzero-length array is always mutable, so it is wrong for a class to have a public static final array field, or an accessor that returns such a field.
  • diormualıntı yaptı4 ay önce
    The Boolean.valueOf(boolean) method illustrates this technique: it never creates an object. This technique is similar to the Flyweight pattern [Gamma95]. It can greatly improve performance if equivalent objects are requested often, especially if they are expensive to create.
fb2epub
Dosyalarınızı sürükleyin ve bırakın (bir kerede en fazla 5 tane)