0

I am a asp.net mvc programmer and if I want to start a project I do this:

  1. I make a class library named Model for my models.
  2. I make a class library named Infrastructure.Repository for database processes
  3. I make a class library named Application for business logic layer
  4. And finally I make a MVC project for the UI.

But now some things are confusing me.

Am I using 3-tier programming? If yes so what is n-tier programming and which one is better? If no so what is 3-tier programming?

Some where I see that the tiers namings are DAL and BIZ.

Which one is correct according to the naming convention?

  • Why don't you simply use namespaces and folders? Unless you have a very specific need to satisfy, it's simpler to use the "Models" folder for Models (which ARE the BLL). – Sklivvz Oct 20 '13 at 13:38
  • I avoid namespace tokens like Infrastructure. It adds no semantic meaning whatsoever and it is entirely subjective whether or not most libraries can be considered "infrastructure" libraries. Namespaces should also almost always be plural or collective nouns, with the possible exception of the main application itself which is normally named something like UI or Web; the worst thing you can do is have a class called Repository in a namespace called Repository. Look at how the BCL does it: System.Collections, System.Data, System.Messaging, etc. – Aaronaught Oct 20 '13 at 21:00
6

This is not a complete answer but it addresses one important point. Namely the difference between layers and tiers.

"It is important to understand the distinction between layers and tiers. Layers describe the logical groupings of the functionality and components in an application; whereas tiers describe the physical distribution of the functionality and components on separate servers, computers, networks, or remote locations. Although both layers and tiers use the same set of names (presentation, business, services, and data), remember that only tiers imply a physical separation. It is quite common to locate more than one layer on the same physical machine (the same tier). You can think of the term tier as referring to physical distribution patterns such as two-tier, three-tier, and n-tier..." for more see: MSDN-Layered Application Design.

2

As an amendment to the above answer (and a bit of a history lesson), "3-tier" and "n-tier" are the same where n=3. Back in the dark ages, application code and data were all in the same assembly (and "computing machines" were the size of rooms). That quickly changed, and "data files" were invented, creating a two-layered (still single-tiered) architecture. Some other things happened, and eventually the RDBMS came along, which was housed on its own computer, and the age of "client-server" computing was born.

Once the concept of separating the concerns of "program logic" (which included presentation-, business-, and application-logic in today's parlance) from "database logic" (persistence) was digested, business and application logic was moved to a "middle-tier", and suddenly we had "three-tier computing". It spread in the early nineties, and coincided with the explosion of the Internet and the World Wide Web.

From three-tier, it was a short logical leap to spreading things across many layers, and separating those layers across many execution environments, sometimes for security, other times for maintenance, often for performance. Tiring of the idea of having to describe things in quickly-increasing numerics, the phrase "n-tier" was born, and really describes any application architecture that spreads itself across multiple execution environments.

Note that today, with virtual machines, multi-core processors, and parallel computing, it's hard to say what code is running on what discreet processor, or how its separated from another "layer" on another "tier", but we like to put things in containers, whether or not the container has any real boundaries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.