Question : n-Tier Architecture

Experts,

I'm creating a new website for customer ordering, and am wondering if I should use 3-tier architecture.  The main feature I'm looking for is separating business logic from data, etc.  How do I go about this?  How is this separation reflected in a class structure?

Answer : n-Tier Architecture

Hi!

N-Tier architecture is always a good practice, even on small projects... it's like an insurance :)
Many initial small projects get bigger in no time, so if you plan ahead you'll avoid having to throw the old code away.

There are many interpretations and implementation of the n-tier, what I'm about to describe is the simple 3-tier implementation.

This said, you need to separate your application in 3 different layers: UI, Business (BL) & Data (DL).

UI
  • Here goes all your user interfaces 
  • No business logic should be implemented inside the interfaces, for that you'll have worker classes on the BL. 
  • Think about it this way: you're developing it for the web, if you need to develop it for windows you should only need to write a new UI layer, no changes on any of the other layers should be needed.
     
Business Layer
  • Here is where your business works 
  • Everything from simple gets and sets of data from the DL to complex business calculations must have a method on the layer. 
  • These methods should be isolated inside classes representing each business object, like: Invoice, Product, Entity, etc... 
Data Layer
  • This one is basically your database. 
  • Here you have your db schema, data, procedures, whatever... 

Feel free to ask about anything you have in mind.

Cheers,
Alex
Random Solutions  
 
programming4us programming4us