Effective Java 3rd Edition -- Creating and Destroying Objects
本章涉及创建和销毁对象:何时以及如何创建它们,何时以及如何避免创建它们,如何确保它们及时销毁,以及如何管理必须在销毁之前进行的清理操作。
- Item 1: Consider static factory methods instead of constructors
- Item 2: Consider a builder when faced with many constructor parameters
- Item 3: Enforce the singleton property with a private constructor or an enum type
- Item 4: Enforce noninstantiability with a private constructor
- Item 5: Prefer dependency injection to hardwiring resources
- Item 6: Avoid creating unnecessary objects
- Item 7: Eliminate obsolete objects references
- Item 8: Avoid finalizers and cleaners
- Item 9: Prefer try-with-resources to try-finally
还没有评论,来说两句吧...