Skip to content

rajbhatta/Java_Creational_Design_Pattern

Repository files navigation

What is creational design pattern

Creational design pattern defines how the object is created beside instantiating with new.

Some of the example of creation design pattern

1. Singleton Pattern

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

2. Builder 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

3. Prototype 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

4. Factory Method Pattern

Link:
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/04-Abstract-factory-design

5. Abstract Factory Pattern

Link:
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/05-FactoryDesignPattern

6. Static Factory Pattern

Link:
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/06-Static_Factory_Pattern

7. Custom Dependency Injection

Link :
https://github.com/rajbhatta/Java_Creational_Design_Pattern/tree/master/07-custom-dependency-injection

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages