473,583 Members | 3,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4804
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.co m> 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.co m> 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
FactoryDataTabl e

in the BL layer:
FactorySomeObje ct
FactorySomeOthe rObject

in the UI layer:
FactorySomeCont rol
FactorySomeForm

Is this correct?

Feb 24 '06 #6
"deko" <de**@nospam.co m> 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
| FactoryDataTabl e
|
| in the BL layer:
| FactorySomeObje ct
| FactorySomeOthe rObject
|
| in the UI layer:
| FactorySomeCont rol
| 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
| FactoryDataTabl e
|
| in the BL layer:
| FactorySomeObje ct
| FactorySomeOthe rObject
|
| in the UI layer:
| FactorySomeCont rol
| 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.co m> 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
2970
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 Intel compiler it has stopped working. I think the singleton pattern static instance thing may be at the root of the problem, but I'm not sure. I had...
4
2517
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 http://www.dofactory.com/Patterns/PatternAbstract.aspx). Could anybody try to explain me in his own words how this pattern work and what the purpose is? thanks in advance
2
1751
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
2533
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 here: http://www.codeproject.com/cs/database/dal1.asp. Business objects encapsulate the data access objects, and know which DA
4
2015
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 for the creation of objects of a type that inherit from a base class. Factory is probably the wrong word here, as it's really a persistance class,...
1
2017
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 interface class containing all the other required interface, or do I expose several separate interface to the DAL? (Seems conceptualy cleaner to provide on...
2
1623
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 this data access layer in my web services developed with Web service software factory to remove the rudundant code? What's the best approach to...
6
1625
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 DAL returns DataSet objects to the facade, which loads the data into a memento object to pass to the ASP.NET interface. For instance, I've got the...
1
3600
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 to a function of a ùregistry vlass that hold all sub-classes... /* ------Neuron.h--------*/ #include <math.h> namespace Mnetlib { class Neuron
0
7894
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8321
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7931
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8191
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5699
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5370
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3816
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1426
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1154
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.