Two-Tier Or Three-Tier?


N by !Raimyu on deviantART

The N-Tier pattern, when used in software development, is one step above my usual topic of design patterns. They are commonly called architectural patterns which are concerned with the software at a macro level (eg. ‘the big picture’).

Some time ago, I was tasked before of maintaining a line-of-business sales system from a fairly large company.Their technical design spec was quite clear that the “…architecture is divided into three (3) main layers…” which, in theory, should make my job easier. As I browsed through the code though, one thing became apparent: It was not a 3-Tier Arch like the docs said, but a more traditional server-client setup~ Now, what is the difference exactly?

A Server-Client architecture (which is, technically, a 2-Tier Arch) is concerned primarily with the centralization of data and sometimes the balancing of process load to either the server or the client. The data and the business rules (stored procs) are stored at the server, with a thin client app to present the results (forms, grids & reports)- which is exactly how the LoB app above works.

S+C’s Advantages over 3-Tier Arch

  • Faster Development (less design, less code)
  • Can offload processes to the server to accommodate for weaker client workstations, or vice versa if the server is the performance bottleneck
  • Can change business logic without re-deploying new software to the user

Three-tier applications on the other hand, is focused on the separation of responsibility to facilitate control and change. The Data Access Layer is usually separated physically such as a Database Server, but is mostly kept “dumb” except for very few performance functions. The Business Logic Layer on the other hand is a more robust collection of libraries and maybe a few dynamic scripts that enforces the rules of the application. This ranges from who can access which data, data validation, up to caching, etc. Lastly, the topmost Presentation Layer is the combination of UI Rendering (Windows Forms, ASP.Net, WPF, etc.) and UI Logic (Parallel processes, Sessions, States, anything that is not business-related logic).

3-Tier’s Advantages over S+C Arch:

  • Modular, and thus easier to maintain. You can replace one layer with another completely with very minimal code changes (switch from Windows Forms to WPF or ASP.Net with zero impact on business logic or database schema)
  • can perform Unit Testing very easily. Since all of the business logic is contained on libraries, you can hook the DLLs easily on a controlled testing environment.

We have to consider both sets of factors above in order to decide which architecture to use when designing our software~

0 comments:

Post a Comment