Creational design pattern defines how the object is created beside instantiating with new.
Introduction
-It guarantee that only instance is created. -It guarantee control of a resource
Example
- Runtime
- Logger
- Spring Bean
- Graphic Manager
Link:
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/01-Singleton-Pattern
Design consideration
Handle complex constructor Enforce immutability once object is created. It can be implemented by creating a separate class for static. It doesn't require interface but we can implement it with interface if required. Can be worked with legacy code.
Link:
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/02-Builder-Pattern
Design consideration
It avoids costly creation operation: Avoid subclassing: we create an instance of the actual prototype that we are trying to work with. Typically doesn't use new keyword: the first instance created might use keyword new after that it is cloned. Often utilize an interface Usually implemented with a registery. Example: java.lang.object#clone()
Link:
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/03-Prototype-Pattern
Link:
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/04-Abstract-factory-design
Link:
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/05-FactoryDesignPattern
Link:
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/06-Static_Factory_Pattern