D
deko
Which layer should a Factory class go in?
DA - Data Access
BL - Business Logic
UI - User Interface
??
DA - Data Access
BL - Business Logic
UI - User Interface
??
else will introduce unnecessary coupling between layers.
| > 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.
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.
purpose:
|
| in the DA layer:
| FactoryDataset
| FactoryDataTable
|
| in the BL layer:
| FactorySomeObject
| FactorySomeOtherObject
|
| in the UI layer:
| FactorySomeControl
| FactorySomeForm
|
| Is this correct?
They are only really suitable for
situations where you have a defined
hierarchy that is intended to be used in a polymorphic way from an
abstract
or virtual base class.
If you don't have such hierarchies, then don't try to use class factories.
And don't try to design hierarchies just so that you can create a factory
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.