Some reasons where you may need private constructor:
- The constructor can only be accessed from static factory method inside the class itself. Singleton can also belong to this category.
- A utility class, that only contains static methods.
More Related Contents:
- What is an example of the Liskov Substitution Principle?
- What is polymorphism, what is it for, and how is it used?
- When to use an interface instead of an abstract class and vice versa?
- Difference between abstraction and encapsulation?
- Monad in plain English? (For the OOP programmer with no FP background)
- Difference between object and instance
- What is the exact problem with multiple inheritance?
- Why can’t I seem to grasp interfaces?
- Is it possible to access struct fields from within a trait?
- HAS-A, IS-A terminology in object oriented language
- Functional programming vs Object Oriented programming [closed]
- Explanation of the UML arrows
- What is the definition of “interface” in object oriented programming
- What is the scope of the Single Responsibility Principle? [closed]
- How much work should be done in a constructor?
- When to use mixins and when to use interfaces in Dart?
- Why “private” methods in the object oriented?
- What is the meaning and reasoning behind the Open/Closed Principle?
- Doctrine2 ORM does not save changes to a DateTime field
- Can’t seem to understand SOLID principles and design patterns [closed]
- What is the real difference between “Bastard Injection” and “Poor Man’s Injection”
- Difference between value parameter and reference parameter?
- Differences between Proxy and Decorator Pattern
- A use for multiple inheritance?
- What is immutability and why should I worry about it?
- adapter-Any real example of Adapter Pattern [closed]
- In SOLID, what is the distinction between SRP and ISP? (Single Responsibility Principle and Interface Segregation Principle)
- When to use a Class in VBA?
- VBA: how to test for object equality (whether two variables reference the same object)
- Overloading functions