473,320 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Factory class - DA, BL, or UI layer?

Which layer should a Factory class go in?

DA - Data Access
BL - Business Logic
UI - User Interface

??
Feb 24 '06 #1
8 4784
The same layer as the object it is designed to create. Put it anywhere
else will introduce unnecessary coupling between layers.

Feb 24 '06 #2
"deko" <de**@nospam.com> a écrit dans le message de news:
_J******************************@comcast.com...

| Which layer should a Factory class go in?
|
| DA - Data Access
| BL - Business Logic
| UI - User Interface

That would depend on whether its a Data Connection factory, a Business
object factory or a UI Widget factory.

Factories are a design pattern that can be used in all sorts of situations.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 24 '06 #3
> 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

??
Feb 24 '06 #4
"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
Feb 24 '06 #5
> |> 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.
And those purposes can vary within 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.


So it would be more appropriate to designate factories according to purpose:

in the DA layer:
FactoryDataset
FactoryDataTable

in the BL layer:
FactorySomeObject
FactorySomeOtherObject

in the UI layer:
FactorySomeControl
FactorySomeForm

Is this correct?

Feb 24 '06 #6
"deko" <de**@nospam.com> a écrit dans le message de news:
ve********************@comcast.com...

| And those purposes can vary within a layer?

Certainly

| So it would be more appropriate to designate factories according to
purpose:
|
| in the DA layer:
| FactoryDataset
| FactoryDataTable
|
| in the BL layer:
| FactorySomeObject
| FactorySomeOtherObject
|
| in the UI layer:
| FactorySomeControl
| FactorySomeForm
|
| Is this correct?

Yes, but don't fall into the trap of creating factories just because you
can. 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
:-)

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 24 '06 #7
> | So it would be more appropriate to designate factories according to
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
rather, best suited 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


I am intent on using a factory class, and will kill anyone that gets in my
way.

Feb 24 '06 #8
"deko" <de**@nospam.com> a écrit dans le message de news:
c4********************@comcast.com...

| rather, best suited for

furry nuff.

| I am intent on using a factory class, and will kill anyone that gets in my
| way.

Then don't let me stand in your way :-)

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 24 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ryan Mitchley | last post by:
Hi all I have code for an object factory, heavily based on an article by Jim Hyslop (although I've made minor modifications). The factory was working fine using g++, but since switching to the...
4
by: max | last post by:
Hello, I analyze this design pattern for a long time but I do not understand how this pattern work and what the purpose is? (I looked a this site...
2
by: Julia | last post by:
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
3
by: Andy | last post by:
Hi all, I'm developing n-tier applications and I'd like some advice. I have my data layer, business layer, and application layers. The data layer uses a method similar to the one described...
4
by: anonymous.user0 | last post by:
Using the dotnet v1.1 framework (so no generics possible). I'd like to create a bunch of Factory classes that all inherit from a single abstract base Factory class. Each Factory is responsible...
1
by: guhar1 | last post by:
A few design issues: 1. If I decide to implement an interface between my "business object layer" and my "data access layer", so as to protect the BOL from changes in DAL, do I provide ONE...
2
by: DotNetGuy | last post by:
I have developed a data access layer in my web site application by using web client software factory and put it in my business module as a service. The question is: Is it a good option to reuse...
6
by: =?Utf-8?B?cml2YWxAbmV3c2dyb3Vwcy5ub3NwYW0=?= | last post by:
Morning, I've got an ASP.NET 2.0 Web Application. Behind it, I've a statically-scoped facade/class factory as the business layer, running atomic functions back and forth from my by DAL. The...
1
by: neoairus | last post by:
I'm developing a pseudo-library for neural network. To simplify librarary using i wont to implement a sistem to instantiate different implementation of interface(Layer.h Neuron.h) passing a string...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.