473,326 Members | 2,090 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,326 software developers and data experts.

Factory pattern

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
object properties map to the Business object properties.. but if the DA
objects change, i'll also have to modify the business layer...
something i'd like to avoid.

So I was thinking of implementing a Factory pattern, where the factory
knows which DOs to use to build the appropriate BOs, but I'm not sure
if this is appropriate (or if there's an even better way).

I'm also trying to figure out where the Factory pattern would fit, if
thats the way to go. Would the apps, using static methods off of
Business objects talk to the business objects that way, or would it
talk to the factories? I'm leaning toward the former.. the Business
layer static methods call the appropriate factory to create the
objects.

Comments?

Thanks
Andy

Nov 17 '05 #1
3 2524
Andy <aj********@capcitypress.com> wrote:
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
object properties map to the Business object properties.. but if the DA
objects change, i'll also have to modify the business layer...
something i'd like to avoid.

So I was thinking of implementing a Factory pattern, where the factory
knows which DOs to use to build the appropriate BOs, but I'm not sure
if this is appropriate (or if there's an even better way).


Have you looked at Spring.NET? I'm currently using Spring in a Java
application, and it's wonderful not to set up any wiring myself...

http://www.springframework.net

(I confess I haven't used the .NET version myself yet, but I suspect
the bean configuring bit is pretty stable.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Jon,
From what I've read so far about it, it provides away to setup config

files that detail how data objects map to business objects. Is that
correct?

Certainly sounds interesting, but isn't this just moving the plumbing
from code to a config file?

Oh, I'll assume that the factory pattern is the way you recommend going
(since Spring is a factory framework, i think)

Andy

Nov 17 '05 #3
Andy <aj********@capcitypress.com> wrote:
From what I've read so far about it, it provides away to setup config
files that detail how data objects map to business objects. Is that
correct?
Well, it sets up general constructor parameters and properties; any
collaborators etc. It doesn't have to be data objects to business
objects.
Certainly sounds interesting, but isn't this just moving the plumbing
from code to a config file?
Absolutely - but IMO that's a major advantage.
Oh, I'll assume that the factory pattern is the way you recommend going
(since Spring is a factory framework, i think)


Well, it all depends on how you set things up - it's very flexible.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4

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

Similar topics

17
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products....
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...
10
by: Chris Croughton | last post by:
What do people call their factory functions? 'new' is not an option (yes, it can be overloaded but has to return void*). The context is: class MyClass { public: // Factory functions...
11
by: FluffyCat | last post by:
In Febraury - April of 2002 I put together in Java examples of all 23 of the classic "Gang Of Four" design patterns for my website. Partly I wanted to get a better understanding of those patterns....
2
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...
1
by: =?Utf-8?B?RXJpYw==?= | last post by:
I am using the factory method to solve a problem where a factory can produce product. I have a base factory class and a base product class. The problem that I am having is that for every product...
16
by: RSH | last post by:
Hi, I am a fairly seasoned developer and have recently started looking at software design patterns. I am starting with the Abstract Factory Pattern and was wondering if someone could help me...
2
by: Duy Lam | last post by:
Hi everyone, Sorry, I don't know what group to post this problem, I think may be this group is suitable. I'm styduing DAO (Data Access Object) pattern in this link...
1
by: DAXU | last post by:
Hi, I am bit confused about the differences between plugin pattern and factory pattern. Can someone explain the differences? Many Thanks Jerry
5
by: CSharper | last post by:
I have created a Factory pattern code. One thing I noticed after coding, each factory has some methods they are exactly same and doing the same code using the values specific to each factory, if I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.