Questions tagged [n-tier-architecture]

N-Tier architecture refers to the architecture of an application that has at least 3 "logical" layers or parts that are separate. Each layer interacts with only the layer directly below, and has specific function that it is responsible for.

An n-Tier application usually has three tiers, and they are called the presentation tier, the business tier and the data tier.

Presentation Layer

Presentation Layer is the layer responsible for displaying user interface and "driving" that interface using business tier

Business Tier

Business Tier is the layer responsible for accessing the data tier to retrieve, modify and delete data to and from the data tier and send the results to the presentation tier. This layer is also responsible for processing the data retrieved and sent to the presentation layer.

Often this layer is divided into two sub layers: the Business Logic Layer (BLL), and the Data Access Layers (DAL). Business Logic Layers are above Data Access Layers, meaning BLL uses DAL classes and objects. DAL is responsible for accessing data and forwarding it to BLL.

Data Tier

Data tier is the database or the source of the data itself.

Logical Layers vs. Physical Layers (Distributed)

Logical Layers and Physical Layers are the ones that confuse people. Firstly, a logical layer means that layers are separate in terms of assembly or sets of classes, but are still hosted on the same server. Physical layer means that those assemblies or sets of classes are hosted on different servers with some additional code to handle the communication between the layers. E.g. remoting and web services.

Conclusion

Why use n-Tier architecture? Because each layer can be located on physically different servers with only minor code changes, hence they scale out and handle more server load. Also, what each layer does internally is completely hidden to other layers and this makes it possible to change or update one layer without recompiling or modifying other layers.

983 questions
198
votes
14 answers

What is N-Tier architecture?

I've seen quite a few developer job postings recently that include a sentence that reads more or less like this: "Must have experience with N-Tier architecture", or "Must be able to develop N-Tier apps". This leads me to ask, what is N-Tier…
Joshua Carmody
  • 13,410
  • 16
  • 64
  • 83
150
votes
12 answers

MVC Vs n-tier architecture

I was wondering what exactly is the difference between MVC(which is an architectural pattern) and an n-tier architecture for an application. I searched for it but couldn't find a simple explanation. May be I am a bit naive on MVC concepts, so if…
Arnkrishn
  • 29,828
  • 40
  • 114
  • 128
77
votes
16 answers

Business Logic in Database versus Code?

As a software engineer, I have a strong bias towards writing business logic in the application layer, while typically relying on the database for little more than CRUD (Create Retrieve Update and Delete) operations. On the other hand, I have run…
senfo
  • 28,488
  • 15
  • 76
  • 106
48
votes
2 answers

Should the repository layer return data-transfer-objects (DTO)?

I have a repository layer that is responsible for my data-access, which is called by a service layer. The service layer returns DTOs which are serialized and sent over the wire. More often than not, services do little more than access a repository…
JulianR
  • 545
  • 1
  • 4
  • 7
41
votes
4 answers

Should service layer classes be singletons?

I am using Spring framework. Should my service classes be created as singletons? Can someone please explain why or why not? Thanks!
oym
  • 6,983
  • 16
  • 62
  • 88
38
votes
3 answers

Onion archicecture dependencies in the same layer: Infrastructure and Web communicating

I am designing an ASP.NET MVC application using the Onion Architecture described by Jeffrey Palermo. It is an ASP.NET MVC 2.0 project, where I am requiring that all views be strongly typed using dedicated View Models -- we will not be passing domain…
38
votes
6 answers

Explain the different tiers of 2 tier & 3 tier architecture?

I am not able to understand which elements are called as first tier, second tier & third tier & where they reside. Can they reside on same machine or different machine. Which tier reside on which machine? How we can identify a particular…
Shailesh Jaiswal
  • 3,606
  • 13
  • 73
  • 124
34
votes
5 answers

Exception handling in n-tier applications?

What is the suggested approach or best practice for handling exceptions in tiered applications? Where should you place try/catch blocks? Where should you implement logging? Is there a suggested pattern for managing exceptions in n-tiered…
flesh
  • 23,725
  • 24
  • 80
  • 97
32
votes
4 answers

What are the main advantages of MVC pattern over the old fashioned 3-layer pattern

I am contemplating about using an MVC pattern in my new project and I can clearly see the main advantage of being able to put the data layer (the model) a little closer to the presentation layer (the view), which will allow a little increase in…
28
votes
6 answers

DTO classes vs. struct

So, this is actually this question is my current keystone. I'm working on refactoring of my personal project, trying increase performance, optimize memory usage, make code easy and clear. I have a different application layers (actually, DAL, BLL,…
Andriy Zakharko
  • 1,623
  • 2
  • 16
  • 37
26
votes
3 answers

Where to put sql when using dapper?

I'm using dapper for a mvc3 project at work, and I like it. However, how are you supposed to layer the application when using dapper? Currently I just have all my sql stuffed directly in the controller (slap) but I was thinking of making a class…
Christian Wattengård
  • 5,543
  • 5
  • 30
  • 43
24
votes
1 answer

How should I persist timestamps in SQL DB if app uses NodaTime?

I want to start using NodaTime in my application to manage times, instants and general time localization. Sometimes I persist timestamps to a SQL Server 2008 database. I had traditionally used datetime2 fields in UTC. These timestamps will be…
Matthew
  • 10,244
  • 5
  • 49
  • 104
24
votes
1 answer

What is difference of developing a website in MVC and 3-Tier or N-tier architecture?

What is difference of developing a website in MVC and 3-Tier or N-tier architecture? Which one is better? What are pros and cons?
Starx
  • 77,474
  • 47
  • 185
  • 261
23
votes
2 answers

How to pass Current User Information to all Layers in DDD

Similar questions have been asked before but not quite the same (unless I missed it) I want to pass IUserInfo class instance through my Service, Domain , Domain Events, Domain Event Handlers... Whats is the best way to do it. Should I Inject it…
TheMar
  • 1,934
  • 2
  • 30
  • 51
23
votes
5 answers

Which layer should i declare enums?

I have a C# N-Layer Project that has 5 Layers: 1-Infrastructure 2-Domain 3-AppService 4-Distributed Service 5-Presentation I want to use enums in my project. but I don't know which layer describe them. I have two ideas about it. 1- declare enums in…
ArMaN
  • 2,306
  • 4
  • 33
  • 55
1
2 3
65 66