Effective Java 40 Design method signatures carefully

Principle

  1. Choose method names carefully.
  2. Don't go overboard in providing convenience methods.
  3. Avoid long parameter lists.
    1. Break the method up into multiple methods. Such as sublist element of List interface.
    2. Create helper classes to hold groups of parameters.
    3. Adapt the builder pattern form object construction to method invocation. See item 2.
  4. For parameter types, favor interfaces over classes.
  5. Prefer two-element enum types to boolean parameters.

    public enum TemperatureScale { FAHRENHEIT, CELSIUS }

上一篇:GCD API 记录 (三)


下一篇:go 学习资源和GitHub库