Abstract Factory Design Pattern

A factory is an object that produces something. In the world of software design, you need a factory object to create a “product” object so you can decouple the logic of the product’s creation from the objects that use that product. The product and its factory are naturally coupled and the logic of creating a product is centralized in the factory. Abstract Factory Design Pattern is a great way of implementing factories. Each factory can produce different families of products. And there can be more than one factory. Two factories can produce same family of products.

I was trying to implement something that is easy to related to and comprehend. So I took an example that involves two factory objects – Honda and Toyota. Each factory can produce two types of products – one car and one aircraft. And the entire object interaction is initiated via a simple client class. The cars expose a ‘drive’ behavior whereas the aircrafts expose a “fly” behavior. All the coding work was using the Visual Studio 2015 Integrated Development Environment and c# programming language.

I have uploaded two videos on the Abstract Factory. The first video mainly focuses on the class diagram of the prototype.

Abstract Factory Design Pattern (Part 1):

The second video does a walkthrough of the implementation. I have tried to create code “on the fly” so I can do a slow walk-through of the design and the code.

Abstract Factory Design Pattern (Part 2):

All the details are in the two videos. Hope you like the videos. If you have any questions, concerns or comments, please feel free to post those in the comments area. Also, I’d like to hear from your a scenarios where you used the concrete factory pattern or the abstract factory pattern. This is part of a series of posts on different design patterns and I’ll post several videos in the near future.