Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Object Oriented / App Design Question

Reply
Thread Tools

Object Oriented / App Design Question

 
 
NOSPAM
Guest
Posts: n/a
 
      09-24-2004
I am designing a web application in asp.net C#, and I created classes (in
..cs files) working with the .aspx pages. Now, for database part....
wondering which way is better:

1. put database connectivity in the Classes, each class has the load/save
data method? Many of my classes are inherited from each other, and since I
am using SQL 2000 which is a relational database makes the job little bit
more complicated.

2. put database connectivity in .aspx pages, then get/put the data from/into
the classes when needed? This sounds easier, but is it a bad design?

Any suggestions are welcome.. thanks



 
Reply With Quote
 
 
 
 
Hermit Dave
Guest
Posts: n/a
 
      09-24-2004
OOAD normally involves slightly more work but has great deal of advantages
in terms of breaking the system down into manageable chunks.

Consider a page where you have user login, registration, profile view and
edit etc. They all related to all users and potentially have independant UI.
So you would have say 4 aspx pages with code behind. But to directly access
the database from those codebehind classes doesnt help code reuse like if
you needed the same data somewhere else.. in that case you would be
repeating the code. So you create a Middletier which essentially channels
call. So all you aspx pages would do is call the middle tier class to get
the data..

The middle tier classes could implement the logic to connect to the database
and fetch the data which you return to the calling function. that way your
aspx page is not way concerned on whether you are using access or sql server
or msde or oracle or sybase. You could go further and use generic data
access block like the one from MS which lets you connect and do queries on
ms sql 7 or above. That way if you change the database all you have to
change is the middle-tier and replace the calls with new library class..

ASPX ==> codebehind for presentation logic >> Middle tier >> Data Access
Tier >> Database. Read up a bit on layed / tiered application design..

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"NOSPAM" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am designing a web application in asp.net C#, and I created classes (in
> .cs files) working with the .aspx pages. Now, for database part....
> wondering which way is better:
>
> 1. put database connectivity in the Classes, each class has the load/save
> data method? Many of my classes are inherited from each other, and since I
> am using SQL 2000 which is a relational database makes the job little bit
> more complicated.
>
> 2. put database connectivity in .aspx pages, then get/put the data

from/into
> the classes when needed? This sounds easier, but is it a bad design?
>
> Any suggestions are welcome.. thanks
>
>
>



 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      09-24-2004
I am not sure I like either. One methodology that works well is the creation
of a persistance layer that controls marshalling the business objects from
the database to your app. You have methods in the class that force the
callback, but the object-relation mapping engine (persistence layer part) is
actually aware of how to get the data back. This is a better OO design, and
you can find examples on open source sites like SourceForge (including
code).

Rockford Lhotka has his own design of a data "persistance" type of engine
that looks promising. It is in both his VB.NET and C# objects books. You can
download the code and adopt it for your site.

Finally, ObjectSpaces will be out in a future Visual Studio. It allows
mapping via an XML Schema. Unfortunately, it has been dumped from Whidbey
timeframe, but you can still get the March preview and play around with the
idea. If you can get a similar method, you will be ready when objectspaces
are finally available.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
"NOSPAM" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am designing a web application in asp.net C#, and I created classes (in
> .cs files) working with the .aspx pages. Now, for database part....
> wondering which way is better:
>
> 1. put database connectivity in the Classes, each class has the load/save
> data method? Many of my classes are inherited from each other, and since I
> am using SQL 2000 which is a relational database makes the job little bit
> more complicated.
>
> 2. put database connectivity in .aspx pages, then get/put the data
> from/into
> the classes when needed? This sounds easier, but is it a bad design?
>
> Any suggestions are welcome.. thanks
>
>
>



 
Reply With Quote
 
NOSPAM
Guest
Posts: n/a
 
      09-24-2004
Does that mean option (1) is better? To be specific, the Classes I wrote
can be act as middle tier, and they all get compiled as .dll put in the
/bin.


"Hermit Dave" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> OOAD normally involves slightly more work but has great deal of advantages
> in terms of breaking the system down into manageable chunks.
>
> Consider a page where you have user login, registration, profile view and
> edit etc. They all related to all users and potentially have independant

UI.
> So you would have say 4 aspx pages with code behind. But to directly

access
> the database from those codebehind classes doesnt help code reuse like if
> you needed the same data somewhere else.. in that case you would be
> repeating the code. So you create a Middletier which essentially channels
> call. So all you aspx pages would do is call the middle tier class to get
> the data..
>
> The middle tier classes could implement the logic to connect to the

database
> and fetch the data which you return to the calling function. that way your
> aspx page is not way concerned on whether you are using access or sql

server
> or msde or oracle or sybase. You could go further and use generic data
> access block like the one from MS which lets you connect and do queries on
> ms sql 7 or above. That way if you change the database all you have to
> change is the middle-tier and replace the calls with new library class..
>
> ASPX ==> codebehind for presentation logic >> Middle tier >> Data Access
> Tier >> Database. Read up a bit on layed / tiered application design..
>
> --
>
> Regards,
>
> Hermit Dave
> (http://hdave.blogspot.com)
> "NOSPAM" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I am designing a web application in asp.net C#, and I created classes

(in
> > .cs files) working with the .aspx pages. Now, for database part....
> > wondering which way is better:
> >
> > 1. put database connectivity in the Classes, each class has the

load/save
> > data method? Many of my classes are inherited from each other, and since

I
> > am using SQL 2000 which is a relational database makes the job little

bit
> > more complicated.
> >
> > 2. put database connectivity in .aspx pages, then get/put the data

> from/into
> > the classes when needed? This sounds easier, but is it a bad design?
> >
> > Any suggestions are welcome.. thanks
> >
> >
> >

>
>



 
Reply With Quote
 
Hermit Dave
Guest
Posts: n/a
 
      09-24-2004
well there are lots of techniques and all have their advantages and
disadvantages. What you use is based on
a. how much seperation you want
b. the hassle you wouldnt mind going into.

I would say that option 1 isnt bad... though you could still drill further
down to increase the seperation.

consider thing.. from every class that access database you will start by
getting the connection string and creating a connection etc. You break that
down further but you have to decide on factors A & B.

You want to look up on what Greg mentioned as well..

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"NOSPAM" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> Does that mean option (1) is better? To be specific, the Classes I wrote
> can be act as middle tier, and they all get compiled as .dll put in the
> /bin.
>
>
> "Hermit Dave" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > OOAD normally involves slightly more work but has great deal of

advantages
> > in terms of breaking the system down into manageable chunks.
> >
> > Consider a page where you have user login, registration, profile view

and
> > edit etc. They all related to all users and potentially have independant

> UI.
> > So you would have say 4 aspx pages with code behind. But to directly

> access
> > the database from those codebehind classes doesnt help code reuse like

if
> > you needed the same data somewhere else.. in that case you would be
> > repeating the code. So you create a Middletier which essentially

channels
> > call. So all you aspx pages would do is call the middle tier class to

get
> > the data..
> >
> > The middle tier classes could implement the logic to connect to the

> database
> > and fetch the data which you return to the calling function. that way

your
> > aspx page is not way concerned on whether you are using access or sql

> server
> > or msde or oracle or sybase. You could go further and use generic data
> > access block like the one from MS which lets you connect and do queries

on
> > ms sql 7 or above. That way if you change the database all you have to
> > change is the middle-tier and replace the calls with new library class..
> >
> > ASPX ==> codebehind for presentation logic >> Middle tier >> Data Access
> > Tier >> Database. Read up a bit on layed / tiered application design..
> >
> > --
> >
> > Regards,
> >
> > Hermit Dave
> > (http://hdave.blogspot.com)
> > "NOSPAM" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > I am designing a web application in asp.net C#, and I created classes

> (in
> > > .cs files) working with the .aspx pages. Now, for database part....
> > > wondering which way is better:
> > >
> > > 1. put database connectivity in the Classes, each class has the

> load/save
> > > data method? Many of my classes are inherited from each other, and

since
> I
> > > am using SQL 2000 which is a relational database makes the job little

> bit
> > > more complicated.
> > >
> > > 2. put database connectivity in .aspx pages, then get/put the data

> > from/into
> > > the classes when needed? This sounds easier, but is it a bad design?
> > >
> > > Any suggestions are welcome.. thanks
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
NOSPAM
Guest
Posts: n/a
 
      09-24-2004
Is this the book I should read?

http://www.amazon.com/exec/obidos/tg...38524?v=glance

I am going to buy if this is the one... Thanks a lot.




"Cowboy (Gregory A. Beamer)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> I am not sure I like either. One methodology that works well is the

creation
> of a persistance layer that controls marshalling the business objects from
> the database to your app. You have methods in the class that force the
> callback, but the object-relation mapping engine (persistence layer part)

is
> actually aware of how to get the data back. This is a better OO design,

and
> you can find examples on open source sites like SourceForge (including
> code).
>
> Rockford Lhotka has his own design of a data "persistance" type of engine
> that looks promising. It is in both his VB.NET and C# objects books. You

can
> download the code and adopt it for your site.
>
> Finally, ObjectSpaces will be out in a future Visual Studio. It allows
> mapping via an XML Schema. Unfortunately, it has been dumped from Whidbey
> timeframe, but you can still get the March preview and play around with

the
> idea. If you can get a similar method, you will be ready when objectspaces
> are finally available.
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> *************************************************
> Think outside the box!
> *************************************************
> "NOSPAM" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I am designing a web application in asp.net C#, and I created classes (in
> > .cs files) working with the .aspx pages. Now, for database part....
> > wondering which way is better:
> >
> > 1. put database connectivity in the Classes, each class has the

load/save
> > data method? Many of my classes are inherited from each other, and since

I
> > am using SQL 2000 which is a relational database makes the job little

bit
> > more complicated.
> >
> > 2. put database connectivity in .aspx pages, then get/put the data
> > from/into
> > the classes when needed? This sounds easier, but is it a bad design?
> >
> > Any suggestions are welcome.. thanks
> >
> >
> >

>
>



 
Reply With Quote
 
Ken Dopierala Jr.
Guest
Posts: n/a
 
      09-24-2004
Hi,

This is a fantastic read and it is free:
http://msdn.microsoft.com/architectu...s/html/Esp.asp

There are also many other patterns and practices that you will benefit from
reading. Understanding these will give you most of the design information
you will need for creating powerful applications. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight

"NOSPAM" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is this the book I should read?
>
>

http://www.amazon.com/exec/obidos/tg...38524?v=glance
>
> I am going to buy if this is the one... Thanks a lot.
>
>
>
>
> "Cowboy (Gregory A. Beamer)" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
> > I am not sure I like either. One methodology that works well is the

> creation
> > of a persistance layer that controls marshalling the business objects

from
> > the database to your app. You have methods in the class that force the
> > callback, but the object-relation mapping engine (persistence layer

part)
> is
> > actually aware of how to get the data back. This is a better OO design,

> and
> > you can find examples on open source sites like SourceForge (including
> > code).
> >
> > Rockford Lhotka has his own design of a data "persistance" type of

engine
> > that looks promising. It is in both his VB.NET and C# objects books. You

> can
> > download the code and adopt it for your site.
> >
> > Finally, ObjectSpaces will be out in a future Visual Studio. It allows
> > mapping via an XML Schema. Unfortunately, it has been dumped from

Whidbey
> > timeframe, but you can still get the March preview and play around with

> the
> > idea. If you can get a similar method, you will be ready when

objectspaces
> > are finally available.
> >
> > --
> > Gregory A. Beamer
> > MVP; MCP: +I, SE, SD, DBA
> >
> > *************************************************
> > Think outside the box!
> > *************************************************
> > "NOSPAM" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > >I am designing a web application in asp.net C#, and I created classes

(in
> > > .cs files) working with the .aspx pages. Now, for database part....
> > > wondering which way is better:
> > >
> > > 1. put database connectivity in the Classes, each class has the

> load/save
> > > data method? Many of my classes are inherited from each other, and

since
> I
> > > am using SQL 2000 which is a relational database makes the job little

> bit
> > > more complicated.
> > >
> > > 2. put database connectivity in .aspx pages, then get/put the data
> > > from/into
> > > the classes when needed? This sounds easier, but is it a bad design?
> > >
> > > Any suggestions are welcome.. thanks
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Joe Fallon
Guest
Posts: n/a
 
      09-27-2004
I use Rocky's CLSA framework in a large ASP.Net.
It works great. The book is one of the best "reads" out there.
There is a whole Users forum available for discussing how to implement CSLA.
http://groups.msn.com/CSLANET/messages.msnw

Petar Kozul has added some *amazing* extensions to the framework with his
ActiveObjects.
http://csla.kozul.info/
--
Joe Fallon



"NOSPAM" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is this the book I should read?
>
> http://www.amazon.com/exec/obidos/tg...38524?v=glance
>
> I am going to buy if this is the one... Thanks a lot.
>
>
>
>
> "Cowboy (Gregory A. Beamer)" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
>> I am not sure I like either. One methodology that works well is the

> creation
>> of a persistance layer that controls marshalling the business objects
>> from
>> the database to your app. You have methods in the class that force the
>> callback, but the object-relation mapping engine (persistence layer part)

> is
>> actually aware of how to get the data back. This is a better OO design,

> and
>> you can find examples on open source sites like SourceForge (including
>> code).
>>
>> Rockford Lhotka has his own design of a data "persistance" type of engine
>> that looks promising. It is in both his VB.NET and C# objects books. You

> can
>> download the code and adopt it for your site.
>>
>> Finally, ObjectSpaces will be out in a future Visual Studio. It allows
>> mapping via an XML Schema. Unfortunately, it has been dumped from Whidbey
>> timeframe, but you can still get the March preview and play around with

> the
>> idea. If you can get a similar method, you will be ready when
>> objectspaces
>> are finally available.
>>
>> --
>> Gregory A. Beamer
>> MVP; MCP: +I, SE, SD, DBA
>>
>> *************************************************
>> Think outside the box!
>> *************************************************
>> "NOSPAM" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I am designing a web application in asp.net C#, and I created classes
>> >(in
>> > .cs files) working with the .aspx pages. Now, for database part....
>> > wondering which way is better:
>> >
>> > 1. put database connectivity in the Classes, each class has the

> load/save
>> > data method? Many of my classes are inherited from each other, and
>> > since

> I
>> > am using SQL 2000 which is a relational database makes the job little

> bit
>> > more complicated.
>> >
>> > 2. put database connectivity in .aspx pages, then get/put the data
>> > from/into
>> > the classes when needed? This sounds easier, but is it a bad design?
>> >
>> > Any suggestions are welcome.. thanks
>> >
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
object oriented design question in context of Java program J W Java 2 06-21-2012 06:33 PM
class-oriented rather than object-oriented? notnorwegian@yahoo.se Python 2 05-26-2008 04:42 PM
Has anybody here read Design Patterns Explained: A New Perspective on Object-Oriented Design John Java 0 06-01-2007 02:45 PM
Object oriented does not mean class oriented rolo Ruby 3 04-09-2004 02:51 PM
is there an object oriented design model asp.net? =?Utf-8?B?c2NvdHRybQ==?= ASP .Net 4 02-27-2004 10:26 AM



Advertisments