Fragmented - An Android Developer Podcast

The Fragmented Podcast is a podcast for Android Developers hosted by Donn Felker and Kaushik Gopal. Our goal is to help you become a better Android Developer. We chat about topics such as Testing, Dependency Injection, Patterns and Practices, useful libraries, and much more. We will also be interviewing some of the top developers out there. Subscribe now and join us on the journey of becoming a better Android Developer.

http://www.fragmentedpodcast.com

subscribe
share






episode 19: 019: Effective Java for Android developers : Item 4


Singer and Android developer Donn Felker explores Joshua Bloch's fourth Item: Enforce noninstantiability with a private constructor.

Stay tuned, cause we got more of these quick ones coming.

  • Effective Java (2nd Edition) - Joshua Bloch

Enforce noninstantiability with a private constructor.

Examples where you don't want class to be instantiated

  1. class that groups static methods and static fields (Util like classes think java.lang.Math/java.util.Arrays)
  2. class that groups static methods (including factory methods) for objects implementing specific interfaces (think java.util.Collections)
  3. class that group methods on a final class (vs. extending the class)

Considerations

  • Makes no sense to instantiate such "Util" classes
  • Private constructors prevent instantiation
  • Important side effect: prevents subclassing
Contact us:
  • @fragmentedcast [twitter.com]
  • @donnfelker [twitter.com]
  • @kaushikgopal [twitter.com]


fyyd: Podcast Search Engine
share








 October 15, 2015  6m