Factory pattern and Abstract Factory

15 views
Skip to first unread message

Axat

unread,
Apr 24, 2011, 1:47:55 AM4/24/11
to UBC CPSC 210
For the Final , are we supposed to know both of them, the Factory
method pattern and the abstract factory pattern or just the Factory
method pattern?

Paul Carter

unread,
Apr 24, 2011, 6:38:02 PM4/24/11
to ubc-cp...@googlegroups.com
You should know both. Note that the Abstract Factory pattern is a fairly straightforward extension of the Factory Method pattern.

Paul

Axat

unread,
Apr 24, 2011, 9:37:00 PM4/24/11
to UBC CPSC 210
Which lecture notes pertain to the singleton pattern?

Paul Carter

unread,
Apr 24, 2011, 10:32:49 PM4/24/11
to ubc-cp...@googlegroups.com
This pattern wasn't covered - please see the study guide for the final exam posted on the course schedule page.

Paul

dslater

unread,
Apr 24, 2011, 11:35:51 PM4/24/11
to UBC CPSC 210
Since Abstract Factory Pattern was not included in our readings is the
Wikipedia page also accurate on that topic?

http://en.wikipedia.org/wiki/Abstract_factory_pattern

On Apr 24, 7:32 pm, Paul Carter <pcar...@cs.ubc.ca> wrote:
> This pattern wasn't covered - please see the study guide for the final exam posted on the course schedule page.
>
> Paul
>

Paul Carter

unread,
Apr 25, 2011, 12:19:08 AM4/25/11
to ubc-cp...@googlegroups.com
It's not bad but the example isn't the greatest as the abstract factory has only one factory method. In general, the abstract factory has a family of related factory methods. You can find a more general example here:

http://www.oodesign.com/abstract-factory-pattern.html

- scroll down to the "look and feel" example and you'll see a more general version of the example on the Wikipedia page you linked to in your message. This more general version is similar to the example we saw in class with the ingredient factory for the pizza store.

Paul

John-Jose

unread,
Apr 25, 2011, 4:40:04 AM4/25/11
to UBC CPSC 210
Just to double check, in the oodesign.com UML, the products should be
dependent on the concrete factories, as opposed to have a uni-
directional association as shown?

Or is that a design decision?

For example, in our pizza example, product PlainDough has a dependency
on WhistlerIngredientFactory? Not a uni-directional association,
because the factory doesn't have an 'instance-level variable' of the
dough?



On Apr 24, 9:19 pm, Paul Carter <pcar...@cs.ubc.ca> wrote:
> It's not bad but the example isn't the greatest as the abstract factory has only one factory method.  In general, the abstract factory has a family of related factory methods.  You can find a more general example here:
>
> http://www.oodesign.com/abstract-factory-pattern.html
>
> - scroll down to the "look and feel" example and you'll see a more general version of the example on the Wikipedia page you linked to in your message.  This more general version is similar to the example we saw in class with the ingredient factory for the pizza store.
>
> Paul
>

Paul Carter

unread,
Apr 25, 2011, 12:13:19 PM4/25/11
to ubc-cp...@googlegroups.com
Good observation.

You've got the right idea but It's the concrete factories that have a dependency on the concrete products, not the other way around. There's nothing in these examples to suggest that there should be an association from the concrete factories to the concrete products.

Paul

Reply all
Reply to author
Forward
0 new messages