Let me begin with a proverb, "
Change is Inevitable & Good." If you are not ready to adapt to the change, you will not survive. Same case applies to our software as well.
Like many of us, I am a big time Fan of PC Games. So, i thought of interpreting the usage and implementation of a pattern on the same lines.
I love "Company of Heroes" game. It has awesome UI and whole lot of Gadgets and i had great time playing it.
Look at UI once.
If you closely observe, there are Cars, Tankers, and Flights. In fact there are different types of each kind.
Now, lets say i have Scenario, where i designed this kind of a game (Lets Assume ;))
I have to handle all these kinds of vehicles say, Tankers. Tomorrow, i got a complain that, the tankers are not efficiently attacking the Aircrafts. Now, i have to categorize Tankers into 2 different types.
1. Ground Tankers.
2. Air Tankers
Tomorrow, there may come another type. And my code should be open to implement any new kind of vehicle that may creep into scope in future.
So, in order to handle families of related and dependent objects, we use "Abstract Factory Pattern".
Coming to Game, when the user starts the game, i have to give him the following vehicles to start off.
1. Soldiers Car
2. Officers Car
3. Passenger Aircraft
4. Soldiers Aircraft
5. Land Tanker
6. Air Tanker.