views:

41

answers:

1

Hi, I need to develop a complex web application, I have already designed (GUI) all the web pages, and the DB. Now I would like to design the code behind and the actual ASP.net (decide using a common base class for different pages, using a control or not, etc....). How do you do that? which models do you use (like inheritance diagram, etc...) ?? Have you got any link to common practices or examples?

Thank you!

+1  A: 

There are few common techniques you could employ to implement model side of things. Among popular design patterns for implementing persistence there are:

  • ActiveRecord - Inherits persistence logic from base class. Usually closely coupled with database logic. It has beautiful implementation in Rails framework.
  • Data Access Object - Powerful solution where persistence is aggregated, not inherited. Provides great flexibility and is suitable for both database and non-database persistence.
  • Table/Row Gateway Interface - Simplistic approach to database persistence. Closely coupled to database and sometimes too limited for given purpose. Example implementation in Zend framework.

As far as model inheritance is concerned, this is now getting tricky, as relational and object oriented paradigms are fundamentally incompatible. To handle inheritance you'd better be off using some ORM mapper, like Hibernate (Java) or Doctrine (PHP). You can have a look at common design patterns related to inheritance:

It's worth mentioning that inheritance modelling problem is non-existent in schemaless databases (like CouchDB). Some database engines (i.e. PostgreSQL) provide table inheritance, but this feature is rarely used.

Update: Since you clarified that you intend to use ASP.NET, you could use NHibernate for .NET or go with LINQ (although I have no experience with either).

Michał Rudnicki