Reputation: 11
Can anybody tell me what is the difference between N-Layer and N-Tier architecture.I know 3-layer architecture has 3 layers: UI, Business Logic Layer(BLL) and Data Logic Layer(Dll)
But now, my question is what is N-Tier and N-Layer and what is the difference between these.
Also how do these interact with one layer to another in respect to C#?
Upvotes: 1
Views: 753
Reputation: 7308
It's about abstraction.
Read wikipedia's article on multitier architecture and it will tell you that indeed layer vs tier is about software vs hardware. But that's not followed rigorously as a peek at the OSI 7 layer model will show you (it's not all software but they call em all layers anyway). And really, that isn't the point. Abstraction is the point.
Be it layer or tier the point is, each level focuses on one clear responsibility and connects to the neighboring layers as little and as simply as possible. Keeping the connections few and simple (loose coupling) allows alternative implementations of a level to be swapped out without disturbing the others. That trick works the same in hardware as it does in software.
So, how to interact with one layer to another in C#? This really depends on what your doing. All your C# code could be the logic tier coordinating the interactions between an html presentation layer with an SQL database layer. Or it could be you have many layers in a game with a model view controller design. In that case all the layers are in C#. Or it could simply be three classes that do three different things. But only if they are connected correctly. What makes them "tiers" or "layers" is that level 1 has to go through level 2 to get to level 3. 1 doesn't talk to 3 and 3 doesn't talk to 1.
But the thing that really makes it work is abstraction. A good database layer makes updating and querying the database easier by hiding unneeded details from the logic layer. Removing those details makes the logic code easier to write and read.
It's the same reason we put hoods on cars. You could take off the hood, sit on the engine block, jam a rod in the rack & pinion assembly, grab the throttle cable, and drive the car. Since the hood's no longer in the way you can now do amazing things like change the oil at 60 miles an hour. Still, I think you'll find you're more comfortable driving with the hood on and behind the wheel with all those engine details abstracted away.
Upvotes: 0
Reputation: 24901
Layer defines logical separation. If you have 3 layers, this means you have 3 separate parts of the system where each is responsible for separate thing.
Tier defines physical separation between layers. It does not mean this must reside in separate machines, but it means that the parts are separate and can be installed and used on their own.
Upvotes: 0
Reputation: 113
It is not the same. Layer is concept of software architech - how you oganize your code. Tier is concept of hardware architech - what machine run a part of your code.
Upvotes: 2