473,699 Members | 2,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

business objects

Hey folks,

I have a toppic I would like to discuss:

Many authors write that business objects should have the CRUD behavior
implemented (create, read, update, delete). Which means that a class
Customer has a method Load() etc...

In my opinion this is not the right way, because this means that you
implement the way a class is saved in the class itself.
What I do is creating DataAdapter classes for the business object. e.g.
XMLDataAdapter, SqlDataAdapter, TxtDataAdapter etc. The all implement
the same interface DataAdapter who has the CRUD behavior.

The way I do it, it is possible to save the same object as a textfile,
as an xml string or in a relational database (Sql Server e.g.)

What do you guys think is the best way?
Mar 2 '06 #1
3 2061
"Rudderius" <dr***@bestopia .be> a écrit dans le message de news:
11************* **@seven.kulnet .kuleuven.ac.be...

| Many authors write that business objects should have the CRUD behavior
| implemented (create, read, update, delete). Which means that a class
| Customer has a method Load() etc...

They are wrong, IMO

| In my opinion this is not the right way, because this means that you
| implement the way a class is saved in the class itself.
| What I do is creating DataAdapter classes for the business object. e.g.
| XMLDataAdapter, SqlDataAdapter, TxtDataAdapter etc. The all implement
| the same interface DataAdapter who has the CRUD behavior.

You are right, also IMO.

| The way I do it, it is possible to save the same object as a textfile,
| as an xml string or in a relational database (Sql Server e.g.)
|
| What do you guys think is the best way?

Separation of database code from business code is highly recommended, as is
the designing of classes before database tables if practicable.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Mar 2 '06 #2
Rudderius wrote:
I have a toppic I would like to discuss:

Many authors write that business objects should have the CRUD
behavior implemented (create, read, update, delete). Which means that
a class Customer has a method Load() etc...
Depends on how you look at things. In software development land, too
many things are considered 'WRONG' and 'THE ONLY RIGHT WAY'. This is of
course nonsense, as it depends on the situation and way of how you look
at things what's wrong and right.

Take your example. One can argue that an object contains data +
behavior. You can argue that having persistence logic in that object is
correct, because it's behavior too.

Others say: "no, that's not good, persistence logic should be factored
into another class". This is OK as well, if you believe the right
philosophy is to keep entity focussed behavior inside the entity object
and persistence behavior outside the entity object. It then becomes a
service, which is applied to the entity objects.

The last group cheats though. If you believe persistence logic
shouldn't be in the entity object, neither should lazy loading. After
all, it's an indirect persistence trigger.

This is particular important, because if you have set up your
application using several tiers, and you force your GUI team to use a
BL tier for all their persistence needs. So the GUI team shouldn't be
able to fetch / retrieve any data from the DB themselves, they should
only utilize the BL tier. You can only achieve that if you use
persistence as a service, and done in full, so no lazy loading as well.
In my opinion this is not the right way, because this means that you
implement the way a class is saved in the class itself. What I do is
creating DataAdapter classes for the business object. e.g.
XMLDataAdapter, SqlDataAdapter, TxtDataAdapter etc. The all implement
the same interface DataAdapter who has the CRUD behavior.
It's a way of doing it. Our o/r mapper supports both philosophies, so
you can take your pick. This is done because not everyone thinks the
same about how things should work or be designed, and as you can't
simply say 'this is right' and 'this is wrong', you can't force one way
of thinking on everyone.

If you firmly think that persistence as a service is the correct way,
for whatever reason (as the reason doesn't matter!), you should follow
that of course, and if you think persistence is behavior, you should
follow that. I can only say that if you think persistence is part of
behavior and you then use a session style / adapter style persistence
object, it's incorrect with the philosophy you've chosen. So 'not the
right way' is only relative to the context of what you think is
correct, and as I tried to explain: there's no golden rule which always
is right or wrong.
The way I do it, it is possible to save the same object as a
textfile, as an xml string or in a relational database (Sql Server
e.g.)

What do you guys think is the best way?


depends.

For a quick and dirty app, having the save logic and lazy loading
inside an entity or entitycollectio n is very productive. Though as I
explained earlier, it might be that in a large team, there are certain
rules which forbid parts of the team to access persistence logic and if
they still want/need to work with entity objects, it's key to have the
persistence logic outside the entities. As I said, it depends. It's not
as black and white as some people want you to believe. Heck, the
majority of software using a database is written with DTO's.

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Mar 3 '06 #3
Joanna Carter [TeamB] wrote:
"Rudderius" <dr***@bestopia .be> a écrit dans le message de news:
11************* **@seven.kulnet .kuleuven.ac.be...
Many authors write that business objects should have the CRUD
behavior implemented (create, read, update, delete). Which means
that a class Customer has a method Load() etc...
They are wrong, IMO


I always find people who claim 'that's wrong', 'that's correct', only
believable if they state why they think it's wrong or right. For the
sake of this important discussion, could you elaborate a bit?
In my opinion this is not the right way, because this means that
you implement the way a class is saved in the class itself.
What I do is creating DataAdapter classes for the business object.
e.g. XMLDataAdapter, SqlDataAdapter, TxtDataAdapter etc. The all
implement the same interface DataAdapter who has the CRUD behavior.


You are right, also IMO.


So, do you also limit lazy loading in these scenario's? Because lazy
loading IS persistence logic. It's an indirect way of accessing the db
through an entity object, and if persistence logic should be outside
the entity (see my other posting why that can be a good way of doing
it, but doesn't have to, thus it depends as with everything databases
;)), lazy loading should too.
The way I do it, it is possible to save the same object as a
textfile, as an xml string or in a relational database (Sql Server
e.g.)

What do you guys think is the best way?


Separation of database code from business code is highly recommended,
as is the designing of classes before database tables if practicable.


Yay, we didn't hear that 'DDD or the highway'-speech in a long time! ;)

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Mar 3 '06 #4

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

Similar topics

25
5055
by: Stuart Hilditch | last post by:
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...
2
1826
by: headware | last post by:
I am new to 3-tiered design and am in the process of designing an application that will work with ASP.NET as well as Windows Forms (and possibly with a PDA of some sort down the road). My question is about the statefulness of business objects. In some of the examples that I've seen of 3-tiered systems using ASP.NET, the business objects are recreated every time they are accessed. They are not kept in the Session variable for use next time...
5
2049
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!
8
1667
by: Keith-Earl | last post by:
Okay, looking for a Best Practice. We are building a classic three tier app in VB.NET. When we load up a WebForm we have access to very useful objects such as the Session object. We frequently store short lists in Session or even Application objects and retrieve them later without having to make a round trip to the db. We think the best place to do all this is in the Business tier and not to clutter up the client (WebForm). In order...
25
2771
by: Penelope Dramas | last post by:
Hello, I'm in a front of very serious .net redesign/rewrite of an old VB6 application. I had been asked to make it .NET 2.0 and would like to ask couple of questions regarding data access as this application is heavily data-centric around MSDE database. Would it be better to use custom business objects or extend
0
8613
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
9172
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
9032
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
7745
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
6532
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
4374
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
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
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.