"deko" <de**@nospam.com> a écrit dans le message de news:
TY******************************@comcast.com...
|> The same layer as the object it is designed to create. Put it anywhere
| > else will introduce unnecessary coupling between layers.
|
| So, should I have a factory in each layer (if needed), like this:
|
| FactoryDA.cs
| FactoryBL.cs
| FactoryUI.cs
Not strictly, no. The Class Factory design pattern can be used for many
different purposes.
Sometimes, you don't need any factories, sometimes you will need more than
one in a layer.
There is no relationship between factories and layers, a class factory is
related to a given class hierarchy where you define abstract behaviour that
will be implemented by differing classes from that hierarchy.
My UI layer could have a form factory, the MVP layer would have an
interactor factory, a presenter factory, a model factory, possibly a view
factory, etc... The business layer could have all sorts of factories,
depending on the nature of the business classes. The data layer could also
have a SQL generator factrory, a connection factory and others.
Google for Design Patterns, Class Factory for examples of whre you could use
a factory.
But *don't* think that you *have* to have a factory in each layer or even at
all. Factories are not essential in an application, unless you really have a
need for them.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer