View on GitHub

effective-java-3rd-edition

Effective Java 3rd Edition Notes

Effective Java - 3rd Edition Notes

Chapter Index

Chapter 02 - Creating and Destroying Objects

Item 1 - Consider static factory methods instead of constructors

Some common names for static factory methods
Conclusion

Avoid the reflex to provide a public constructor and consider static methods/factories.

Item 2 - Consider a builder when faced with many constructor params

Item 3 - Enforce the singleton property when a private constructor or enum type

Item 4 - Enforce non-instantiability with a private constructor

Item 5 - Prefer dependency injection to hard-wiring resources

Item 6 - Avoid creating unnecessary objects

Item 7 - Eliminate obsolete object references

Item 8 - Avoid finalizers and cleaners

Item 9 - Prefer try-with-resources to try-finally

Chapter 03 - Methods Common to All Objects

Item 10 - Obey the general contract when overriding equals()

Item 11 - Always override hashCode() when overriding equals()

Item 12 - Always override toString()

Item 13 - Override clone() judiciously

Item 14 - Consider implementing Comparable

Chapter 04 - Classes and Interfaces

Item 15 - Minimise the accesibility of classes and members

Item 16 - Favour accessors over public fields in public classes

Item 17 - Minimise mutability

Item 18 - Favour composition over inheritance

Item 19 - Design and document for inheritance or else prohibit it

Item 20 - Prefer interfaces to abstract classes