Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 6th, 2007, 05:05 PM
Authorized User
 
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Last question before I see your next article. If you prefer to mix data and behavior then why re-writing the article with a different design with business objects being passed between BLL and DAL. That I assume is based on your discussion with Peter, can I ask about that discussion that made you change the article. You are changing it, so I will assume you are making it even better, although you like the current design. Why would that be?

Tahir

 
Old February 6th, 2007, 05:09 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:However, in my current implementation, they also break the idea of completely separate layers.
What I like, and what's best for me is more than often not the same.... ;)

I'll cook something up, like the BugBase, with a Bug (BO) and BugManager (BLL) class....

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old February 6th, 2007, 05:15 PM
Authorized User
 
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for being a pain in neck. Let me rephrase my question actually. You have two implementations, you like one and you think one is better. But what are the benifits of approach that is best (seperate BO, BLL, DAL), there has to be benifits over the approach you 'like' otherwise you would'nt implement it. What are those benifits?

Tahir

 
Old February 6th, 2007, 05:19 PM
Authorized User
 
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

A question not directly related to this topic but related to you :). In the book Instant Results, which are the chapters you wrote? I am asking because there are three authors and I am not sure how things work while writting books by multiple authors.

Tahir

 
Old February 6th, 2007, 05:25 PM
Authorized User
 
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

You took your article off-line, actually I asked there about performance issue. What if the layers are on seperate machines, is there is a performance problem when having data and behavior together? Lightweight business objects (fields only) are better in those conditions or not?

Tahir

 
Old February 6th, 2007, 05:53 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You ask a lot of questions which is good, but I am not sure I can answer them all all the time.

The benefit of the BO / BLL / DAL design is that each of the layers is independent of the other. In my original implementation, the BO/BLL object was tied to the DAL in that it accepted an IDataReader to fill itself. Peter brought up the question: "and what if your data comes from an XML file?".

With having a BO (fields / data only), a BLL (methods, validation, security maybe) and a DAL (data access, using objects from the BO) you get a cleaner separation.

It's a constant struggle between "proper design", time to market, accessibility of the design to others and so on. The initial design from my article works, as many apps that I have running demonstrate. However, it's not as "pure" as it could be.

Check out the intro of the book; it lists the chapters I wrote.

Re: performance: I wonder if it matters. "Behavior" isn't serialized when using, say, XML Web Services, only data, so I wonder if serializing the data into "surrogate counterparts" for your real objects would be slower or faster when the object also contains behavior.

Are you familiar with the book Expert C# 2005 Business Objects by Rockford Lhotka?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old February 6th, 2007, 05:57 PM
Authorized User
 
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

I know about the book but have'nt read it. Is it worth reading (buying) it?

Tahir

 
Old February 6th, 2007, 05:59 PM
Authorized User
 
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Thank you a lot of answering my questiosn and being patient. I will wait now till I see you revised article then will ask more questions... :)

I must say that these discussions with you have already helped me a lot. I am thankful to you from all my heart.

God bless you.

Tahir

 
Old February 6th, 2007, 06:04 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:I know about the book but have'nt read it. Is it worth reading (buying) it?
What kind of answer do you expect if you ask one of the authors???

OF COURSE IT IS!!! What are you still doing here? Off to Amazon.com to order it..... ;)

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old February 7th, 2007, 11:08 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

On Performance: I agree with Imar. Only the data of a class is serialized (and at that, only the PUBLIC data). So I don't think there is a significant performance difference between a "smart" and "dumb" class.

Regarding organization of classes: I feel that classes that provide data transport as well as processing logic (i.e. 'Smart' classes), break the purist design of multi-layer architecture.

Let's consider the application (app), business logic layer (BLL), data access layer (DAL), and business objects (BO) for the "smart" class approach. Here are a few givens:

1. BO classes defined in BLL
2. app needs to talk to BLL
3. BLL needs to talk to DAL

In this scenario, you can't consume the BO classes in the DAL because you'd get circular references. Therefore, your DAL logic has to work completely independent of BO knowledge. Thus, you have to have BLL methods that create objects from data structures. I see this as a conflict to business/data logic separation. The business logic layer contains data logic.

Having a standalone business object (BO) library allows you to consume it by the business layer (to work with the objects) and the data layer to persist and retrieve the objects.

It also provides these advantages:

- Portability: you can reuse the data shells without carrying around any logic that may not apply to the application you're reusing them in. (Although, typically you would not reuse a set of classes without some similar business logic, they would usually go hand-in-hand).

- SOA: I could create a thin-client application that will do the majority of it's work through a web service. I can include the BO library in my application without any logic behind it. My web services could accept and return XML containing serializations of the BO classes. An important distinction to note here: when you make a native .Net web reference, a proxy class is created that defines class stubs that represent the classes exposed by the web service. While the public interface to these classes appears similar they are not the same class types as the business objects on the service side.

So you have to write the services a little different. One way is to have them accept and return strings of XML (versus a strongly typed object). You need to de/serialize the objects on either end yourself. I realize this increases the complication of code and negates the automatic plumbing that .Net does for you, but in the end results in a more consistent application structure because you are truly using the same class types on both ends of the service.

To provide further flexibility to the design:
If you have a completely self contained data access layer you can implement interfaces on its classes. Then you program the business layer against those interfaces instead of against concrete class types such that you can swap out the data access classes, or even the entire library itself. This could permit you to switch (using a simple configuration switch) what type of data source you want to use: RDBMS, XML, remote service (web/remoting), etc.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding ComboBox inside ListView problem gunnjamie Windows Presentation Foundation 1 July 17th, 2008 02:13 PM
Binding SQLDataSource To A Label Control sg225551 ASP.NET 2.0 Basics 1 January 16th, 2008 10:36 AM
TextBox inside GridView michurin ASP.NET 2.0 Basics 2 January 13th, 2007 12:51 PM
DropDownList inside a GridView aidoco ASP.NET 2.0 Basics 0 October 13th, 2006 04:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.