General

What is a tier? What is difference between layer and tier?

Layers are logical way of organizing code. For example: Presentation Layer, Business Layer & Data Layer(traditional 3-tier architecture, but that did not mean that code will be deployed on different processes). But "Layer" word does not talk about if the layer is part of same process (JVM) or not.

Tier mentions about where the code runs. Thus it talks of physical deployment. That means two tiered will run in different processes (and thus different memory space).

What do we need Layers & Tiers?

Layers: Code maintenance, easier code, untangled code, reuse(across applications), etc Overall it reduces development time.

Tiers: Layers are tiered for performance, scalability, fault tolerance & security.

Is Layering & Tier-ing good?

Layer is always good (if not done to an extreme, e.g. interface for everything).

Tier-ing is not always.The cost of network calls is very very high. Plus added network maintenance, overhead, etc.

Thus, the tradeoff of having tiers needs to be evaluated between performance vs scalability & fault tolerance.

2-tier vs 3-tier(software architectural patterns)?

2-tier has two components - Client & Server. 2nd component is generally the DB. In VB world, client is the Application Code & Server is DB. In Web World, Cleint is the Web Application talking to DB.

3-tier: is the most common architecture which is composed of Client Tier, Business/Logic Tier (middle Tier) & Data Tier.

3-tier vs n-tier?

n-tier (or multi-tier) architecture is a software architectural pattern in which presentation, business & data functions are logically separated (which is 3 tier). In n-tier, further applications are segregated as tiers (e.g. Current Banking application talking to Mainframe tier).

This diagram illustrates that a normal JEE application is viewed as 3-tiered application.

3-tier vs MVC?

3-tier architecture is linear, in the sense client never talks to DB but through Business/middle tier.

MVC architecture is triangular, view sends updates to controller, controller sends updates to model and view gets updates directly from model.

MVC is used exclusively for Presentation layer

Reference:

  1. http://stackoverflow.com/questions/120438/whats-the-difference-between-layers-and-tiers

  2. http://www.lhotka.net/weblog/ShouldAllAppsBeNtier.aspx

  3. http://en.wikipedia.org/wiki/Multitier_architecture