Classic Business Object OOP vs Microsoft bound controls OOP

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
acgtAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sasapopovicCommented:
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
acgtAuthor Commented:
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
sasapopovicCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.