By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,965 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,965 IT Pros & Developers. It's quick & easy.

Abstract factory and Application layers

P: n/a

Hi,

I have an application composed from layers like the following

A
--B
---C

A is the top layer
C uses an Abstract Factory to Create Concrete classes
I wonder if A should create the concrete factory,pass it to B,and than B
will pass it to A
or maybe it is better to create a Concrete factory in B

what are the advantages in disadvantages in each approaches?
create the Concrete factory in the upper most layer
or in the a layer which is one level higher that the layer which uses the
factory?

Thanks
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
hello Julia,

I honestly have to think about what you mean by "layers" because this
doesn't seem to be the same as Buschmann's Layers pattern.

I think you are saying this:
The 'A' layer is a set of interfaces and base classes.
The 'B' layer is a set of concrete classes inherited from 'A' and
The 'C' layer is composed of the collaborating objects (the controllers) who
need to use the classes in 'B'. You want to know where to create your
concrete factory derived from your Abstract Factory base class.

In B.

The concrete factory is, by definition, coupled to the classes it creates.
All factory methods have to know the name of the object that they create
(that's their point). (Factories aren't the only way to abstract object
creation, of course, but that is too much for a Newsgroup posting :-).

Therefore to have "layers" that are cohesive in nature, you want your
concrete factory to be packaged in with the classes that it creates. If I
guessed about your layered structure correctly, then you would place the
abstract factory in A (since it defines types in A), the ConcreteFactory
that inherits from the AbstractFactory in B, and the FactoryFactory in B
(since it creates types of type AbstractFactory, and those types are
declared in B).

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Julia" <co********@012.net.il> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...

Hi,

I have an application composed from layers like the following

A
--B
---C

A is the top layer
C uses an Abstract Factory to Create Concrete classes
I wonder if A should create the concrete factory,pass it to B,and than B
will pass it to A
or maybe it is better to create a Concrete factory in B

what are the advantages in disadvantages in each approaches?
create the Concrete factory in the upper most layer
or in the a layer which is one level higher that the layer which uses the
factory?

Thanks

Nov 16 '05 #2

P: n/a
hello Julia,

I honestly have to think about what you mean by "layers" because this
doesn't seem to be the same as Buschmann's Layers pattern.

I think you are saying this:
The 'A' layer is a set of interfaces and base classes.
The 'B' layer is a set of concrete classes inherited from 'A' and
The 'C' layer is composed of the collaborating objects (the controllers) who
need to use the classes in 'B'. You want to know where to create your
concrete factory derived from your Abstract Factory base class.

In B.

The concrete factory is, by definition, coupled to the classes it creates.
All factory methods have to know the name of the object that they create
(that's their point). (Factories aren't the only way to abstract object
creation, of course, but that is too much for a Newsgroup posting :-).

Therefore to have "layers" that are cohesive in nature, you want your
concrete factory to be packaged in with the classes that it creates. If I
guessed about your layered structure correctly, then you would place the
abstract factory in A (since it defines types in A), the ConcreteFactory
that inherits from the AbstractFactory in B, and the FactoryFactory in B
(since it creates types of type AbstractFactory, and those types are
declared in B).
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Julia" <co********@012.net.il> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...

Hi,

I have an application composed from layers like the following

A
--B
---C

A is the top layer
C uses an Abstract Factory to Create Concrete classes
I wonder if A should create the concrete factory,pass it to B,and than B
will pass it to A
or maybe it is better to create a Concrete factory in B

what are the advantages in disadvantages in each approaches?
create the Concrete factory in the upper most layer
or in the a layer which is one level higher that the layer which uses the
factory?

Thanks

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.