Coffeehouse Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

I dont see any difference between Abstract method and Abstract factory -Have you find any difference ( both of them decouples the client from object creation)

Back to Forum: Coffeehouse
  • User profile image
    Surendiran Bala

    I dont see any difference between Abstract method and Abstract factory - both of them decouples the client from object creation.

    If anybody knows the actual difference please explain me with differences

    Also i dont understand "families of related or dependent object "..why we need to create families of related objects instead we can simply go for factory method rite ?


    Abstract method:-

    Abstract factory :


    look at the above code...both samples are looks similar except in the Abstract factory delegates the object creation to another class..thats the only difference i can see.....Any thoughts?

  • User profile image

    It's "factory method" not "abstract method", which is something else entirely.

    The factory method pattern is used to allow derived classes to control what concrete type of object is created. It's a very specialized pattern. The abstract factory, on the other hand, is more broad, where a factory object is used to create concrete object instances.

  • User profile image

    I'd suggest purchasing DoFactory's .NET patterns stuff if the GoF book is too opaque. DoFactory give useful examples, and optimised .NET code

  • User profile image

    @Surendiran Bala:

    it backs down to the same Abstract vs Interface argument. If you use interface, your factory can implement both ICanMakeAnimal and ICanMakeMachine, and the LandFactory can make both land animal and land machine.

    If you use Abstract class, it is single inheritance. Not sure how you would want to do for the same effect.


    Leaving WM on 5/2018 if no apps, no dedicated billboards where I drive, no Store name.
    Last modified

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.