tags:

views:

156

answers:

2

hi,

I am writing ASP.NET website in which i break code into layer like form object class, Entity classes for business logic, Controller classes to control multiple entity class and finally data access classes.

All above mentioned class have their saperate dll(s) because Form object an business classes are shred among multiple component of project like website and Apllication (Exe)

I have following doubt

  1. I would like to know whether i am doing right approach as per layered programming or not?

  2. Where should we create object of class inside constructor of parent class or with in a function; Because in my case there are around 8-10 child class need to used inside parent class so where should i create clhild class object in constructor of parent class or inside function of parent class where i am using child object?

  3. As mentioned above layered approach, in which layer i should create database connection?

Please help me?

A: 
Kane
A: 

I would like to know whether I am doing the right approach

If you mean from a "Layered" architecture perspective, then I would say yes. The idea is to create different layers of responsibility. In your case you are layering your application like:

  • UI Layer
  • Business Logic Layer
  • Controllers Layer - Possible improvement would be to move this into the Business Logic Layer and make it a separate namespace i.e. BusinessLogic.Controllers
  • DAL (Data Access Layer)

Which seems fair enough IMO.

You should really take a look at the The Repository Pattern. This basically creates a controller class which connects to your database (on create of the object) and then exposes methods (for that particular class) which will interact with your database. Your application also has an MVC feel to it, you should consider using the ASP.NET MVC Framework

James