Pattern: Part 3 (Abstract Factory Pattern)

In a word Abstract factory pattern can be described as a pattern of a super factory which creates other factories. This pattern provides a better way when creating a object.
Let us consider the continuation from the first blog of this series and let us not get confused with factory pattern

3 banks were using the card services in previous blog, now the card services is still an interface but let us think that one of the bank started provide 3 cards according to the customer choice.

and three types of card (Mastercard, visa, amex) are implementing the service
Amex Card

Master Card

Visa Card

Now the bank has another service to provide cheque books and they provide 50 leaf check book for business account, 25 leaf cheque book for current account and 5 leaf cheque book for savings account. The interface of cheque book service is below

The class for the business, current and savings accounts are below

Now we are creating a abstract class below

And implementing that 2 create a factory for card services

Also creating a factory for cheque service

Now creating an enum to make the next steps more understandable.

And then creating a factory which will create those two factories.

Now form the main method we will declare

And then

And then preparing to see the output


Git link is provided here to download

2 thoughts on “Pattern: Part 3 (Abstract Factory Pattern)”

  1. Pure Primal Garcinia Review

    Sweet blog! I found it while browsing on Yahoo News. Do
    you have any suggestions on how to get listed in Yahoo News?

    I’ve been trying for a while but I never seem to get there!
    Many thanks

  2. Pure Primal Garcinia

    Having read this I believed it was really informative. I appreciate you taking the time and energy to put this content together.
    I once again find myself personally spending way too much time both reading and posting comments.
    But so what, it was still worthwhile!

Leave a Reply

Your email address will not be published. Required fields are marked *