
019: Effective Java for Android developers : Item 4
About this episode
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.
Enforce noninstantiability with a private constructor.
Examples where you don't want class to be instantiated
- class that groups static methods and static fields (Util like classes think java.lang.Math/java.util.Arrays)
- class that groups static methods (including factory methods) for objects implementing specific interfaces (think java.util.Collections)
- 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]
Get every episode summarized
Each time Fragmented - AI Developer Podcast publishes, we email you a written briefing from the transcript — the topics, who appeared, and any specific claims, with the ad reads skipped.
Email me new episodesFree for 3 shows. No card needed.
Hosts & guests
No transcript yet
This episode has not been transcribed. Request it and it moves to the front of the queue.
More episodes
More from Fragmented - AI Developer Podcast

311 - Self learning harnesses are here
Fragmented - AI Developer Podcast

310 - Mitchell Hashimoto on Ghostty & His Agentic Coding Workflow
Fragmented - AI Developer Podcast

309 - Background Agents
Fragmented - AI Developer Podcast

308 - How Image Diffusion Models Work - the 20 minute explainer
Fragmented - AI Developer Podcast