473,763 Members | 7,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing Business Objects through nTier Web App

Hi all,

I am hoping that someone with some experience developing nTier apps can give
me some advice here.

I am writing an nTier web app that began with a Data Access Layer (DAL),
Business Logic Layer (BLL) and User Interface Layer (UIL).

The problem I found with this was circular referencing...

My objects would be defined in the BLL, so let's say for example that I want
to instantiate a new BLL.Customer object in the UIL, and then run
Customer.AddCus tomer() which would in turn pass the object into the DAL,
let's call this method DAL.AddCustomer (BLL.Customer myCustomer) which would
insert into the DB.

The problem is that the BLL needs to reference the DAL and the DAL needs to
reference the BLL (to receive the custom business object), hence a circular
referencing error. I understand that I could turn this custom object into
some sort of generic object[] or collection and pass it then, or
alternatively pass the method field values one by one (not practical with
10+ values)

What I did was to create a 4th 'vertical' layer which I called the ORL
(Object Reference Layer), the purpose of which is to allow all other layers
to reference the same objects so they can be passed between themselves
without issues. The drawback is that for this to work properly you need to
have the objects themselves defined in the ORL, but the methods defined
statically in the BLL.

My question is this...

Is this good programming?

Obviously it would be ideal to have the object constructor and instance
methods declared in the same class, but I can't seem to get this to work
effectively any other way.

I would appreciate any advice.

- Stu
Nov 17 '05
25 5062
"Stuart Hilditch" <st************ *@gmail.com> wrote in message
news:y1******** **********@news-server.bigpond. net.au...
Hi Michael,

Sounds like your doing the same thing I am only using datasets rather than
business objects. I would have thought that your application would take a
massive performance by using datasets in this way, especially if you use a
lot of objects. I suppose you can help with caching (if it's an option).

- Stu


Hi Stu,

Why would you think there would be a massive performance hit? Where do you
think that would occur? I know datasets can be slow if they are loaded with
thousands of records, but I'm designing my app to avoid scenarious like
that.

I chose to use datasets for several reasons:

1.) They pass easily through web services. You can pass custom types,
but it requires manually changing the reference.cs file each time.
2.) They have built-in support for remembering which rows get added,
edited, deleted, etc. This is especially true in a data grid. If you pass
your data object to a data grid, how do you know which rows got updated?
3.) They allow for very easy data binding on Windows forms.
4.) You can give custom sql scripts to a data adapter, then let it do all
of the data manipulation work for you. There is no need to loop through
each record manually and figure out whether it needs to be added, deleted,
etc.
5.) You can use DataSet1.GetCha nges() to only pass only the changes to
your web service and then to your data layer.
...

Thanks,

Mike
Nov 17 '05 #21
Hi Mike,

I would tend to think they were better in cases where you use thousands of
records.

I agree they are very handy, but there is a very instantiation & marshalling
cost that is incurred everytime you create a new object.

From
http://msdn.microsoft.com/library/de...tml/BOAGag.asp

"High instantiation and marshalling costs. DataSets result in the creation
of several subobjects (DataTable, DataRow, and DataColumn), which means that
DataSets can take longer to instantiate and marshal than XML strings or
custom entity components. The relative performance of DataSets improves as
the amount of data increases, because the overhead of creating the internal
structure of the DataSet is less significant than the time it takes to
populate the DataSet with data."

I would not use them for individual objects, but for large sets of data they
are great.

When retreiving data from a datastore, a datareader is the way to go if
performance is a consideration. Check out this benchmark ...

http://www.devx.com/vb2themax/Articl...7/1954?pf=true

- Stu

"Michael Rodriguez" <mi**@nospamfor me.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
"Stuart Hilditch" <st************ *@gmail.com> wrote in message
news:y1******** **********@news-server.bigpond. net.au...
Hi Michael,

Sounds like your doing the same thing I am only using datasets rather
than business objects. I would have thought that your application would
take a massive performance by using datasets in this way, especially if
you use a lot of objects. I suppose you can help with caching (if it's an
option).

- Stu


Hi Stu,

Why would you think there would be a massive performance hit? Where do
you think that would occur? I know datasets can be slow if they are
loaded with thousands of records, but I'm designing my app to avoid
scenarious like that.

I chose to use datasets for several reasons:

1.) They pass easily through web services. You can pass custom types,
but it requires manually changing the reference.cs file each time.
2.) They have built-in support for remembering which rows get added,
edited, deleted, etc. This is especially true in a data grid. If you
pass your data object to a data grid, how do you know which rows got
updated?
3.) They allow for very easy data binding on Windows forms.
4.) You can give custom sql scripts to a data adapter, then let it do
all of the data manipulation work for you. There is no need to loop
through each record manually and figure out whether it needs to be added,
deleted, etc.
5.) You can use DataSet1.GetCha nges() to only pass only the changes to
your web service and then to your data layer.
...

Thanks,

Mike

Nov 17 '05 #22
Hi Stu,

I've read those benchmarks and it did give me some concern. However,
there's something I still don't understand about using custom entities to
store your data. If you bind a grid to your business object, how do you
know which rows get changed? How do you know which rows need to be added
and/or deleted?

Also, do you have to pass your business objects through a web service (I
do)? Web services aren't great for passing custom types like that...

Thanks,

Mike
"Stuart Hilditch" <st************ *@gmail.com> wrote in message
news:B0******** **********@news-server.bigpond. net.au...
Hi Mike,

I would tend to think they were better in cases where you use thousands of
records.

I agree they are very handy, but there is a very instantiation &
marshalling cost that is incurred everytime you create a new object.

From
http://msdn.microsoft.com/library/de...tml/BOAGag.asp

"High instantiation and marshalling costs. DataSets result in the creation
of several subobjects (DataTable, DataRow, and DataColumn), which means
that DataSets can take longer to instantiate and marshal than XML strings
or custom entity components. The relative performance of DataSets improves
as the amount of data increases, because the overhead of creating the
internal structure of the DataSet is less significant than the time it
takes to populate the DataSet with data."

I would not use them for individual objects, but for large sets of data
they are great.

When retreiving data from a datastore, a datareader is the way to go if
performance is a consideration. Check out this benchmark ...

http://www.devx.com/vb2themax/Articl...7/1954?pf=true

- Stu

Nov 17 '05 #23
Michael Rodriguez wrote:
Hi Stu,

I've read those benchmarks and it did give me some concern. However,
there's something I still don't understand about using custom entities to
store your data. If you bind a grid to your business object, how do you
know which rows get changed? How do you know which rows need to be added
and/or deleted?
All that should be catered for in IBindingList.
I havent actually implemented deletion, but have done add's.
Also, do you have to pass your business objects through a web service (I
do)? Web services aren't great for passing custom types like that...

Im not sure

<snip)

JB
Nov 17 '05 #24
Hi Mike,

I think it really depends on the context of the problem. Generally I use a
mix of business objects and datasets, I find that custom entities give me a
lot more control, you can use them as a collection and there are a number of
interfaces that will allow you more control over binding, etc.

I also use datasets when a large quantity of data is moving from my Data
Access Layer to my User Interface Layer relatively unchanged, but I would
usually implement caching in that case. Unfortunately I have not had any
experience with web services, but you can easily serialize business objects
so I imagine it can be done.

Hope this helps.

- Stu

"Michael Rodriguez" <mi**@nospamfor me.com> wrote in message
news:eo******** ******@TK2MSFTN GP15.phx.gbl...
Hi Stu,

I've read those benchmarks and it did give me some concern. However,
there's something I still don't understand about using custom entities to
store your data. If you bind a grid to your business object, how do you
know which rows get changed? How do you know which rows need to be added
and/or deleted?

Also, do you have to pass your business objects through a web service (I
do)? Web services aren't great for passing custom types like that...

Thanks,

Mike
"Stuart Hilditch" <st************ *@gmail.com> wrote in message
news:B0******** **********@news-server.bigpond. net.au...
Hi Mike,

I would tend to think they were better in cases where you use thousands
of records.

I agree they are very handy, but there is a very instantiation &
marshalling cost that is incurred everytime you create a new object.

From
http://msdn.microsoft.com/library/de...tml/BOAGag.asp

"High instantiation and marshalling costs. DataSets result in the
creation of several subobjects (DataTable, DataRow, and DataColumn),
which means that DataSets can take longer to instantiate and marshal than
XML strings or custom entity components. The relative performance of
DataSets improves as the amount of data increases, because the overhead
of creating the internal structure of the DataSet is less significant
than the time it takes to populate the DataSet with data."

I would not use them for individual objects, but for large sets of data
they are great.

When retreiving data from a datastore, a datareader is the way to go if
performance is a consideration. Check out this benchmark ...

http://www.devx.com/vb2themax/Articl...7/1954?pf=true

- Stu


Nov 17 '05 #25
Stu,

It's true that business objects can be serialized and passed through a web
service. The problem is the default proxy class does not know about your
custom type. This means every time you update your web reference, you have
to go into the Reference.cs file and add a reference to your custom type.
The was definitely the case for .NET 1.1. I haven't verified yet whether or
not that has changed for 2.0.

Mike

"Stuart Hilditch" <st************ *@gmail.com> wrote in message
news:Tm******** **********@news-server.bigpond. net.au...
Hi Mike,

I think it really depends on the context of the problem. Generally I use a
mix of business objects and datasets, I find that custom entities give me
a lot more control, you can use them as a collection and there are a
number of interfaces that will allow you more control over binding, etc.

I also use datasets when a large quantity of data is moving from my Data
Access Layer to my User Interface Layer relatively unchanged, but I would
usually implement caching in that case. Unfortunately I have not had any
experience with web services, but you can easily serialize business
objects so I imagine it can be done.

Hope this helps.

- Stu



Nov 17 '05 #26

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

Similar topics

11
3185
by: Arsen Vladimirskiy | last post by:
Hello, If I have a few simple classes to represent Entities such as Customers and Orders. What is the proper way to pass information to the Data Access Layer? 1) Pass the actual ENTITY to the Data Access Layer method -or- 2) Pass some kind of a unique id to the Data Access Layer method
3
4759
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing around chunks of data in DataTables/DataSets, simply because that was the format that they were in when the data was taken from the database. Now, I know this maybe a pretty silly question with a standard "it depends" answer, but I'm going to...
4
2578
by: Jack | last post by:
Hi, I have a hashtable that I need to pass around to different Business Objects. My question is it better to pass it and make a locale hashtable variable and set it equal to the passed hashtable or should I pass it and not worry about it? Thanks
3
2685
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/Anch_EntDevAppArchPatPrac.asp I use my own classes in the Business layer. I want to keep the Data Access layer from requiring these classes so I tried passing a Datarow between the layers and it seems to work good for me. Constructing the datarow in the Class...
12
5342
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded the custom employee class and have built it as a separate library (employee.dll). This employee.dll is being referenced by both the web service and the windows application. I face the following problem when I send this class to the webservice.
11
2570
by: Peter M. | last post by:
Hi all, I'm currently designing an n-tier application and have some doubts about my design. I have created a Data Access layer which connects to the database (SQL Server) and performs Select, update, delete and inserts. I use dataset objects to pass data to and from the DAL. In my GUI (windows forms), I use databinding to bind controls to a datatable
3
1366
by: waheed azad | last post by:
Hi, I have a been developing an accounting system for a non-profit organization. I had decided to to divide the solution, in three layers, presentation, business layer and database layer. My business layer is composed of objects like Account, Transaction, Voucher etc. And my database layer is composed of objects like AccountDB, TransactionDB, VoucherDB. Now each of my layer is residing in a seperate project under the same solution....
2
2642
by: grawsha2000 | last post by:
Greetings, I am developing this N-tier business app. The problem I'm facing is when I try to pass business objects (employees, dept..etc) from business tier to data tier,i.e., the add method in the data tier expects business object from the business tier, I get an error saying: Can not covert businesslayer.emp to businesslayer.emp
2
2472
by: Andrus | last post by:
Winforms UI assembly has static FormManager.FormCreator method which creates forms taking entity as parameter. I need to pass this method to business objects in business assembly so that business methods can also create forms but does not have reference to UI assembly. I tried code below but got compile errows shown in comments. How to fix ? Andrus.
0
9564
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9823
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7368
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2794
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.