JavaOne Question

1、Boolean.getBoolean(name);,It does not do as it is liked;
       
        return s.equals("yes") || s.equals("y") ||s.equals("true")|| s.equals("t");
                返回boolean以上代码更好。
               
    suggestion:
        >Strange and terrible methods lurk in libraries
            * Some have innocuous sounding names
        > If your code misbehaves
            * Make sure you’re calling the right methods
            * Read the library documentation
2、Don’t extend classes that weren’t designed for it
    *     If you do, your code may work, but it will be fragile
    *     If it doesn’t say it’s designed for extension, it isn’t
    > Prefer composition over inheritance
    > For API designers
        * Design and document for inheritance or prohibit it
3、Never call an overridable method from a constructor (or “pseudo-constructor”)
4、Autoboxing blurs but does not erase distinction between primitives and boxed primitives
    > Only four of the six comparison operators work
    properly on boxed primitives
        * <, >, <=, and >= work; == and != do not
    > It’s very hard to test for broken comparators
5、All static fields of enums are uninitialized during construction of enum constants
6、Non-static nested classes contain invisible
    reference to enclosing instance
    > Most nested classes should be static
        * Make it static unless you need enclosing instance
    > ThreadLocal value must not reference its instance
    > WeakHashMap value must not reference its key
    > Even Bob Lee makes mistakes
        * This one brought down Google Ads server (preproduction)
7、Constant variable references are inlined
    * Only primitives and strings can be constant
    * null is not a constant
    > If you change a constant’s value withoutrecompiling its clients, they break
        * Use constants field only if value will never change
        * Use ident for final fields whose value may change

你可能感兴趣的:(Google)