In this video, learn how to implement a simple version of the Builder pattern. See how using a complex constructor can be replaced with an implementation of the Builder pattern.
- [Instructor] In this example,…there is an application with a complex constructor…that will benefit from using the builder pattern.…The application has a class called Bedroom…which has eight different fields.…It also has an Architect class…that can be used to create Bedroom objects.…In the application's current state,…it is only possible to create a Bedroom if all eight pieces…of information are supplied.…None of them are optional,…because they are all used in the single constructor…of the Bedroom class.…It is also very difficult…to tell what all the different information…is about when a Bedroom object is created.…
It is also a requirement…of this application to have flexibility.…It should be able to create a Bedroom with any combination…of these pieces of information.…One option is to go about implementing…a different constructor for all of the implementations.…This would take a very long time to write out,…and make our room class very long and messy.…A better idea is to implement the builder pattern.…In the builder pattern,…
Released
8/29/2018- What are creational design patterns?
- Avoid complex constructors
- Implementing the Builder pattern
- Multithreading with the Singleton pattern
- Using the Prototype pattern
- Implementing a simple Factory Method pattern
- Making code more flexible with the Abstract Factory pattern
Share this video
Embed this video
Video: Implement the Builder pattern