effective-java
effective-java copied to clipboard
Exploration of Effective Java, third edition
Effective Java
This project contains examples, tests, and benchmarks for my YouTube series on Effective Java, Third Edition.
The tests can be run with mvn test
or any IDE with JUnit 5 integration.
To run the benchmarks:
mvn package
java -jar target/benchmarks.jar
Related links:
- affiliate links to Effective Java, Third Edition:
- InformIT (the publisher)
- Amazon USA
- Amazon Germany
- visit codefx.org for links to my blog, Twitter, Twitch, and online courses on Java
Creating and destroying objects
- Item 1: Consider static factory methods instead of constructors - examples
- Item 2: Consider a builder when faced with many constructor parameters - examples
-
Items 3-5 -
examples:
- Enforce the singleton property with a private constructor or an enum type
- Enforce noninstantiability with a private constructor
- Prefer dependency injection to hardwiring resources
- Item 6: Avoid creating unnecessary objects - benchmark
Methods
- Item 50: Make defensive copies when needed - example and tests