Fragmented - Android Developer Podcast

019: Effective Java for Android developers : Item 4


Listen Later

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)
    4. 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]
        • ...more
          View all episodesView all episodes
          Download on the App Store

          Fragmented - Android Developer PodcastBy Donn Felker, Kaushik Gopal

          • 5
          • 5
          • 5
          • 5
          • 5

          5

          68 ratings


          More shows like Fragmented - Android Developer Podcast

          View all
          Design Details by Brian Lovin, Marshall Bock

          Design Details

          361 Listeners

          Developer Tea by Jonathan Cutrell

          Developer Tea

          402 Listeners

          Does Not Compute by Sean Washington, Rockwell Schrock

          Does Not Compute

          53 Listeners

          Toolsday by Una Kravets, Chris Dhanaraj

          Toolsday

          48 Listeners

          Swift Unwrapped by JP Simard, Jesse Squires, Spec Network, Inc.

          Swift Unwrapped

          90 Listeners