Hi, I'm in my second year of computer science and we're currently learning about design patterns. As part of this we have been given an assignment to include the Abstract Factory design. I'm having trouble understanding exactly how it fits together so I was wondering if someone could explain, in the most basic terms they can, how it all works.

Recommended Answers

All 5 Replies

YOu have a Factory, that makes objects of some specific type. Maybe you want to use a different Factory depending on some run-time consideration. If all your Factories extend an AbstractFactory class then you can create the appropriate Factory once at the beginning, then use it via the abstract superclasses's interface regardless of which actual Factory it is.

So am i just looking at having abstract classes linking down to a final concrete class or is there something more to how the different methods interact with each other?

An abstract class with some concrete classes, yes. But these classes are all Factories.

Thank you far all the help. I'm somewhat more sure of what i'm doing now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.