473,760 Members | 10,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Am i thinking correctly?? business objects inserting to database

hi guys,

Currently converting an old classic asp system to a OOP asp.net
application. We are building the new application using a 3 tier
arcitecture and i was wondering about the following.

I have a parent class, that when inserted, inserts a few child classes
into the database, based on other classes. In the old system, this is
wrote as one big SQL script, with many inserts and updates because the
system was not wrote as OOP.

Since we are now moving to an OOP design, am i right in thinking that
we should write this code within the Business tier, using objects?? or
does it not really matter? I am wondering about the best practices for
this?

Anyone? Thanks again

Sep 15 '06 #1
1 1884
Nemisis wrote:
hi guys,

Currently converting an old classic asp system to a OOP asp.net
application. We are building the new application using a 3 tier
arcitecture and i was wondering about the following.

I have a parent class, that when inserted, inserts a few child classes
into the database, based on other classes. In the old system, this is
wrote as one big SQL script, with many inserts and updates because the
system was not wrote as OOP.

Since we are now moving to an OOP design, am i right in thinking that
we should write this code within the Business tier, using objects?? or
does it not really matter? I am wondering about the best practices for
this?

Anyone? Thanks again
What I generally do is create a class for each business object. For
example there would be a Order object and an OrderDetail object. The
classes themselves know nothing of the database. They simply contain
the data for the order and its details. We call these Value Object

Next I create Data Access layer that knows how to take a Value object
and insert, update, deleting and selecting it from the database. The
data layer knows nothing of business rules. It simply knows how to get
and save each Value object type in the database. The data layer
contains all the SQL queries and boilerplate to connect to the the
database We call these data providers.

Lastly there is a business controller. The controller knows when to
call the data layer to save the value objects or how to call the data
layer to retrieve objects. If the business controller selects an Order
object, then it also calls the data layer to select the order details.
It also enforces the business rules for each object.

The UI would then reference the Business Layer and would not know
anything about the data access methodology or business rules. It would
simply handle the presentation of the individual objects on the screen.
Here is an example:

//Value Objects

class Order
{
int OrderId;
List<OrderDetai lDetails;
}

class OrderDetail
{
string description;
string quantity;
}

//Data Layer
class SQLOrderProvide r
{
Order GetOrderById(in t id);
List<OrderGetAl lOrders();
void InsertOrder(Ord er o);
List<OrderDetai lsGetOrderDetai ls(Order o);
}

//Business Layer
class OrderController
{
private SQLOrderProvide r _orderProvider;
Order GetOrderById(in t id)
{
Order o = _orderProvider. GetOrderById(id );
o.Details = _orderProvider. GetOrderDetails (o);
return o;
}

List<OrderGetAl lOrders();
void InsertOrder(Ord er o)
{
//perform business logic and validation before calling data
layer
_orderProvider. InsertOrder(o);
}

List<OrderDetai lsGetOrderDetai ls(Order o);
}

We sometime code the business controller against an interface so that
can provide implementations for SQLServer, or Oracle and the back end
can be changed just by dropping the appropriate assemblies.

This is the classic 3 tier setup. It's possible that you would have
other tiers depending on the complexity of your project and your
business rules.

Hope this helps some.

Good Luck

Sep 15 '06 #2

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

Similar topics

2
279
by: Balaji | last post by:
Hi I have three database tables - Location, Part and Detail. Location and Part have a one-many relationship to detail. Location and Part need to be inserted into the database before inserting a detail record. I am having problems designing the business entity objects for these tables becoase we have one composite that Depends on Two Parent Objects.
16
3037
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
5
3139
by: Shibu | last post by:
Hi, I have a situation where I need to convert business objects to a flat table. The reverse is also required. I am using c# and Oracle ODP. I am looking for an easier method to do the below steps. Steps I follows for populating Business Objects is as follows (1) Get a list of records containing various tables joined together from DB using a single PL/SQL (This is a specific requirement, So cannot change the design)
9
6263
by: Hasan O. Zavalsiz | last post by:
Hi , i am trying to figure out which approach is better to use . let me explain the scenario. i am using the "Nortwind" database . in this database i have "Customers " table .The following is the two different ways to handle this table. CASE 1 : create a struct that encaplusates table "Customers" columns public struct structCustomers { public string CustomerID;
5
2053
by: G. Stewart | last post by:
The word "Business" in the term implies some sort of commercial aspects or connotations. But from what I can see, that is not necesserially the case at all? So what is the reasoning behind the term? Stupid question, I know ... and quite irrelevant in many ways ... but I really would like to know!
7
1734
by: Dries | last post by:
Hey, I have been looking around for a few weeks now to find a kind of framework to work with Business Objects. Especially to connect Business Objects with a database system. What I want is something like ADO.NET but instead of using DataTables and DataSets I want to use Business Objects and Collections of them. I just hate the idea that all data from a database should be represented as in a database (that is what ADO.NET does!).
1
2204
by: MariusI | last post by:
I have some business objects which overrides Equals to provide syntax equality instead of just reference equality. Overriding equals gives me a warning that i must override GetHashcode(). Msdn says this about implementing hashcode: (1)If two objects of the same type represent the same value, the hash function must return the same constant value for either object. (2)For the best performance, a hash function must generate a random...
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....
12
3603
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a gridview, for example, I loop through a datareader, populating an array list with instances of a custom class in the middle tier, and then send the array list up to the presentation layer and bind the gridview to it. If I use a typed dataset, I...
0
9333
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10107
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
9945
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
8768
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
7324
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
6599
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5361
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2733
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.