[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Classic Business Object OOP vs Microsoft bound controls OOP

Posted on 2008-02-04
3
Medium Priority
?
266 Views
Last Modified: 2013-11-26
While I have some non-professional experience in programming I have over the past few weeks attempted to upskill myself with classic OOP skills under the ASP.NET 2.0 environment. At first glance I was quite impressed with the ability to write objects that can be bound to data controls. However I soon began to struggle as, after a while, I worked out that I had been trying to combine classic OOP structures where, for example, object properties are maintained via that GET and SET structures, with Microsoft data bound structures where, as far as properties go, they are accessed outside the object (rather than as direct properties) via published datasets.

Do I need to go one way and not the other? Can anyone tell me if there is an effective way to combine these approaches? Am I thinking about it the right way? Are there any good examples of industry strength asp.net business objects that access a database (SQL Server)?  

I know my question is a bit opaque, however Im not 100% sure if I am thinking about this the right way, so any assistance would really be appreciated
0
Comment
Question by:acgt
  • 2
3 Comments
 
LVL 9

Expert Comment

by:sasapopovic
ID: 20813331
Hi acqt,

I always use Business entity classes (classic OOP classes with public properties for attributes that should be bound to ASP.NET controls). I didn't find any issues with using that approach and I never use DataSets in ASP.NET projects.
There are a number of reasons for that but one that is very important to me is exchange of data with external interfaces. For example, if you have a business entity class called User and you need to have it as a parameter in Web Service method then as far as I know, any programing language that is capable of consuming the web services will be able to handle it. On the other hand, if you use DataSets then you may find problems when you want your web services to be consumed by other platforms.

There are performance and reusability issues that I found with DataSets and even more and using custom business entity classes is more OOP approach in my oppinion.

I hope this will help you deciding on how to proceed.

Regards,
Sasa
0
 

Author Comment

by:acgt
ID: 20813828
Thanks for this.....

When you say you bind public properties of classic oop classes to asp.net controls, to what method do you do this. Do you do it in code behind or do you use the ObjectDataSource (as seems to be pushed on us by MS).

I've not found how to bind classic properties to controls and I cant find any examples. do you have, or know where I can find what is considered an "industry" standard example of what you are describing?


Thanks
0
 
LVL 9

Accepted Solution

by:
sasapopovic earned 1500 total points
ID: 20813942
I don't use ObjectDataSource.

I usually have a strongly typed collection of items that I bind to an ASP.NET control. In some cases I bind a single instance of my Business entity class to an ASP.NET control (like in case of DetailsView control).

It usually goes like this (this is only an example):

DeliveryComponent deliveryComponent = new DeliveryComponent();//This is my business logic component
List<DeliveryType> deliveryTypes = deliveryComponent.GetDeliveryTypes();
myDropDownList.DataSource = deliveryTypes;
myDropDownList.DataValueField = "DeliveryTypeID";
myDropDownList.DataTextField = "Name";
myDropDownList.DataBind();

So in example above I used a class DeliveryType with public properties DeliveryTypeID and Name; I got a list of those entities and binded that to a DropDownList control.

There are a number of samples for how to bind the data to ASP.NET controls without the ObjectDataSource (just google for them). Btw, I think ObjectDataSource may introduce additional overhead (because of reflection) and may decrease performances of your pages.

I hope I understood and answered to your questions.

Regards,
Sasa
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question