Can you bypass a layer for a certain operation in a layered architecture?

StackOverflow https://stackoverflow.com/questions/6067029

  •  06-09-2020
  •  | 
  •  

Вопрос

In an n-layered (5-layer, let's say) application, if there are options available for a certain operation to bypass one of the layers and communicate with the next layer directly, can it still be called an "n-layer" architecture, or does it turn into an (n-1)-layered (4-layer) architecture?

And should the layer in question, which you can bypass, be considered as a "layer" at all?

EDIT: I'm trying to implement an application with following structure -
Presentation layer (contains WPF grids)
Application layer (contains application logic and workflow as application services, extracts display model objects from domain model objects, which are then bound to the UI grids)
Domain layer (contains domain model objects only)
Repository (stores data fetched from the database, isolates the lower layers from the upper layer)
Data mapping layer (maps domain model objects to data model objects)
Data access layer (contains data model objects, and stores and retrieves data to and from the database)
-each one above is implemented as separate project and the domain layer is referenced by the application layer, repository and data mapping layer. Now the thing is, the application layer is directly communicating with the repository, not through the domain layer and the domain layer (if I can call it a layer at all) is acting just like a cross-cutting reference. So that's where my question comes, should I call it domain "layer"? I think NOT. But in domain-driven Design there exists a domain layer, right? There must be something wrong in my architecture? Where and what is it?

Это было полезно?

Решение

You could have as many layers as you want and call it an n-layered system...whether they are used properly or loosely coupled is another question.

The fact that you talk about bypassing a layer may mean you've over engineered a solution or you have implemented a layer in an unhelpful/incorrect way...You'd need to be providing some samples of usage to really help out more here...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top