Object Oriented / App Design Question

Discussion in 'ASP .Net' started by NOSPAM, Sep 24, 2004.

  1. NOSPAM

    NOSPAM Guest

    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
    NOSPAM, Sep 24, 2004
    #1
    1. Advertising

  2. NOSPAM

    Hermit Dave Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    >
    Hermit Dave, Sep 24, 2004
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    >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
    >
    >
    >
    Cowboy \(Gregory A. Beamer\), Sep 24, 2004
    #3
  4. NOSPAM

    NOSPAM Guest

    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" <> wrote in message
    news:%...
    > 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" <> wrote in message
    > news:...
    > > 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
    > >
    > >
    > >

    >
    >
    NOSPAM, Sep 24, 2004
    #4
  5. NOSPAM

    Hermit Dave Guest

    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" <> wrote in message
    news:eek:...
    > 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" <> wrote in message
    > news:%...
    > > 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" <> wrote in message
    > > news:...
    > > > 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
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Hermit Dave, Sep 24, 2004
    #5
  6. NOSPAM

    NOSPAM Guest

    Is this the book I should read?

    http://www.amazon.com/exec/obidos/tg/detail/-/1590593448/102-2184915-4738524?v=glance

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




    "Cowboy (Gregory A. Beamer)" <> wrote in
    message news:...
    > 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" <> wrote in message
    > news:...
    > >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
    > >
    > >
    > >

    >
    >
    NOSPAM, Sep 24, 2004
    #6
  7. Hi,

    This is a fantastic read and it is free:
    http://msdn.microsoft.com/architect...x?pull=/library/en-us/dnpatterns/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" <> wrote in message
    news:...
    > Is this the book I should read?
    >
    >

    http://www.amazon.com/exec/obidos/tg/detail/-/1590593448/102-2184915-4738524?v=glance
    >
    > I am going to buy if this is the one... Thanks a lot.
    >
    >
    >
    >
    > "Cowboy (Gregory A. Beamer)" <> wrote in
    > message news:...
    > > 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" <> wrote in message
    > > news:...
    > > >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
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Ken Dopierala Jr., Sep 24, 2004
    #7
  8. NOSPAM

    Joe Fallon Guest

    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" <> wrote in message
    news:...
    > Is this the book I should read?
    >
    > http://www.amazon.com/exec/obidos/tg/detail/-/1590593448/102-2184915-4738524?v=glance
    >
    > I am going to buy if this is the one... Thanks a lot.
    >
    >
    >
    >
    > "Cowboy (Gregory A. Beamer)" <> wrote in
    > message news:...
    >> 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" <> wrote in message
    >> news:...
    >> >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
    >> >
    >> >
    >> >

    >>
    >>

    >
    >
    Joe Fallon, Sep 27, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2NvdHRybQ==?=

    is there an object oriented design model asp.net?

    =?Utf-8?B?c2NvdHRybQ==?=, Feb 24, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    468
    =?Utf-8?B?c2NvdHRybQ==?=
    Feb 27, 2004
  2. John
    Replies:
    0
    Views:
    581
  3. Replies:
    2
    Views:
    411
    Bruno Desthuilliers
    May 26, 2008
  4. rolo
    Replies:
    3
    Views:
    167
    Robert Klemme
    Apr 9, 2004
  5. J W
    Replies:
    2
    Views:
    389
Loading...

Share This Page