Monday, March 26, 2012

Performance with OO approach

At the moment, I use adhoc data access to load data. I am looking at moving away from this and using classes instead. Lets take an example - I am making a booking system for a doctor's surgery. At the moment, I would load the data for a single booking straight from the database. So I would create a SqlCommand, and use a stored procedure to retrieve the values I want.

I want to move this into a seperate class. This would make it a lot easier to manage. So I would have a class called clsBooking. Within this class I would have functions such as:

Struct Booking BookingID as integer PatientName as varchar'''' etc. etc.End StructFunction getBooking (BookingID) as BookingFunction getBookingForPatient (PatientID) as Booking()etc.etc.

What I want to know is how this will impact the performance of my website. I do not expect more that 5 concurrent users at one time, so I do not see a huge problem. I would still like to know what issues I may face though.

Thanks for any help

Jag

Hi,

for all my asp.net programs i have implemented a complete object oriented business layer. I have no problems with performance with this systems. But why you use a struct instead a class? I think you should implement a class like this:

class Booking
{
private int bookingID = 0;
... other variables...

public Booking(int id)
{
Create object and load data ...
}

public int BookingID
{
get
{
return bookingID;
}
}
... and so on ...
}

Regards
Marc André


I am new to this - so I will be learning as I go. So far I have used a struct because I was loading the information for the logged in user and saving this in the session. I did not want to load the user data every time the pages loaded, but I also needed something that was serialisable.

I also like it because the code looks cleaner (rather than having a lot of public variables, I have one struct I access and I know what information I can get for that booking).

This is a simplified example. I am actually designing this for a survey with tickboxes - and so I could anything above and beyond 50 fields I need to load into the class.

One problem I am not sure how to handle is a search datagrid. I have a filter with a lot of choices, and I build the sql query dynamically through code. I'm not sure how this fits into the OO approach.


Hi,

on MSDN exists a good Tutorial about OO and ASP.NET:http://msdn2.microsoft.com/en-us/library/bb332381.aspx

Regards
Marc André

0 comments:

Post a Comment