From my understanding of the concept, Abstract factory creates interfaces for different objects that are related to each other or depend on each other, such that there is no specific concrete class. In simple words, it encapsulates a group of individual factories having same essence.
The client uses same interface to generate objects that are part of it, the client does not know about which concrete objects it gets its requests served because of generic interfaces. This patterns separates the details of implementation of set of objects from clients.
This pattern is used when;
- When a system is independent of how it is implemented
- system needs to configure with one of multiple families of products
Uses of using this pattern are;
- Isolation of concrete classes; they becoming independent of how the system is implemented from client side
- exchanging of different families of products because easy because they all belong to same set
Perhaps an analogy of abstract factory would make it easy to understand; Taking example of Electric hair cutting machine, it has different grades. Short, Medium and large. The amount of hair person would like to cut depends on the grade being used. For example; if you want short hairs, you might use grade 1, if you want medium then maybe grade 3.
Each different grade acts like a factory and the machine acts like a class. As soon we plug the grade in to the machine then grade inherits the properties of abstract (machine). The machine doesn't care about which grade you are using, its sole purpose is to cut hairs, only the grade would decide the amount of hairs its going to cut.
8 comments:
Do u mean it supports multiple interfacing so that it can be implemented ??
Same class is used to control the objects that are made out of it, the purpose is to isolate concrete classes and make them independent of how the system is implmented from client side.
Can you please advise on its aplicability.
Because what I know is that it provides a class library and then shows their interfaces without going through the phase of implementation.
"Can you please advise on its aplicability.
Because what I know is that it provides a class library and then shows their interfaces without going through the phase of implementation."
The purpose of adapter pattern is to separate the system implementation from the client side. Perhaps the example i have given would make it moe clear..
Hi Abbas,
I read about Abstract Factory from many different sources but most of them use the same examples of the Window look and feel. There are others but I was not able to understand the idea to its full extent because the examples were not simple enough (Or may be I am not wise enough!). Anyway, your description is simple and to the point.
Moreover, I must give you all the credit for an even simpler example. I’ve noticed from you other posts that you tried to keep the examples simple as possible for a better understanding but in this post you exceeded yourself. A very thoughtful example and a really good posting. Well done!
Zaman
Well that's what the whole point is Zaman, keep it simple so that everybody understands it. By the way, this habbit of giving simple examples from real life is actually an inspiration from Dr. Sri.
Dr. Sri always comes up with examples that are simpler and easy to understand, thus it conveys the message clearly. I am sure you'll agree with me.
anyways thanks for your comments guys..
hallo,
i like the simplicity in your work mostly on the examples you have placed in your postings. i have learnt quite alot by going through your work.
keep up
don't you think Abstract factory is quiet interesting? I was wondering why i didn't think of applying this pattern in my proposal for my project design.i wish i had enough knowledgeon it.i look forward to using it anytime the opportunity arises. thnanks
Post a Comment