In this video, discover how to implement the Abstract Factory pattern method. See how using an Abstract Factory method can make code more flexible.
- [Instructor] In this example…there is an application that builds bikes…and that uses the abstract factory pattern.…However, as the application gets more complex,…the abstract factory becomes more complex too.…The Factory Creator class has a method called createFactory…and this takes the type of bike needed as a parameter.…If mountain bike is passed in,…it will return a mountain bike factory…that can create mountain bike parts.…And if road bike is passed in,…it will return a road bike factory…that can create road bike parts.…
These factories both extend…an abstract class called BikeFactory.…If I open the BikeFactory class,…it has two methods called createTire and createHandlebar.…Obviously, in reality, more than just tires…and a handlebar are needed to make a bike.…There will also need to be brakes, gears,…a saddle, pedals, and so on.…There might also be other types of bike…that need to be created…besides mountain bikes and road bikes.…A more complete version of the application…might have a class called Saddle,…
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: Dealing with extensible factories