![]() ![]() To demo this, let's make some abstract classes representing the generic kinds of recipes (these are our AbstractProduct participants): /// Further, let's make the assumption that adults and kids don't eat the same things, and so we want one of each kind of recipe for adults and children. Let's say we want to model two kinds of recipes: a Sandwich and a Dessert. But what if wanted to model several families of objects, not just one?įor this demo, let's go more general and model entire sets of recipes. In that example, sandwiches could be considered a family of related objects. something edible between two slices of bread. The thing about sandwiches is that they no matter what they are made of (turkey, roast beef, veggies, peanut butter and jelly) they're still sandwiches, e.g. When we modeled the Factory Method pattern, we did so using sandwiches. The Client uses the AbstractFactory and AbstractProduct interfaces.The Products define a product object that will be created by the corresponding ConcreteFactory.The AbstractProduct declares an interface for a type of product.The ConcreteFactory objects implement the operations defined by the AbstractFactory.The AbstractFactory declares an interface for operations which will create AbstractProduct objects.Project for this post: AbstractFactory The Participants
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |