Creational Design Patterns in Java
- 1 hour on-demand video
- 5 downloadable resources
- Full lifetime access
- Access on mobile and TV
- Certificate of Completion
Get your team access to 4,000+ top Udemy courses anytime, anywhere.Try Udemy for Business
- Design Patterns
This video tutorial talks about Singleton design pattern in Java. A singleton is required in an application if there is a need of only one instance of that type. For example, in Java Virtual Machine, Runtime is singleton as there must be only one runtime instance in a JVM.
Singleton can be implemented in multiple ways:-
Lazy Initialization (Thread Safe)
Lazy Initialization (Double checking)
Bill Pugh Implementation
There are several ways singleton can be exploited and singleton implementation must take care of these issues:-
This video lecture talks about factory design pattern in Java. As the name suggests, a factory is generally used to create object of specific types. In general, there are interface or abstract classes as the parent class and multiple sub-classes implements/extends parent type behavior and provide more specific behavior. A factory can create all these sub types.
This video lecture talks about builder design pattern in Java. A builder design is a creational design pattern and is used to build objects. It is specifically useful when the object has many optional parameters. Through builder pattern, we can force the user to provide only the mandatory parameters and then provide optional setter method to add optional parameters based on the need.
This video lecture discusses prototype design pattern in Java. As the name suggests, it is used to create objects from a prototype. It is useful in situations when creating the actual object directly is costly. For example, each object creation may fetch data from network or database severs and thus requires time to prepare the object. With prototype design pattern we can create the base object and keep the data ready. For each subsequent object references, we clone the existing object and return to the caller.
This video talks about abstract factory design pattern. An abstract factory pattern is factory of factories. In factory pattern, we have seen how we can create specific types of objects which belongs to a particular parent type. This design pattern takes the same concept one level further. In abstract factory pattern we create factory from multiple factory options and then get the required object from the selected factory.
- Should have basic knowledge in Java
In this series, we discuss design patterns in Java. We focused on what is design pattern and different types of pattern. We then closely looked into the Creational design patterns. We talked about Singleton, Factory, Builder, Prototype and Abstract Factory design patterns. Each design pattern is discussed with real life examples and demonstrated with live coding.