N-tier architecture

I am in a situation that I have to develop and implement a system from scratch. I have some questions about architecture that I would like to share your comments and thoughts about.

Project Summary: This is a data-driven web application.

The application will be built on the basis of Microsoft.NET Framework 4.0 with the MS SQL SERVER 2008 database.

Demand:

  • Rich user interface and reliable
  • Support for multiple devices (each browser and on each device)
  • Loose bound

The following is the architectural diagram I built:

enter image description here

Architecture Briefing

  • Presentation level: HTML5 / ASP.NET MVC + JQuery (web application for supporting multiple devices in the first version)
  • Distributed Services: WCF (XML / JSON / JSONP)
  • Domain Level (Business Level): All Business Logic
  • Data Transfer (DAL Layer): Entity Framework 4.0 with a basic database approach. POCO objects are generated and shared using the T4 template.
  • Infrastructure level: Contains shared libraries such as POCO objects, exception handling, logging, etc.

My problems:

  • How an application should be built loosely coupled , so in the future, if business needs grow, new modules can be easily connected without affecting the architecture. So I thought about using the Repository pattern with IoC and DI (maybe Unity / Ninject / Sprint.NET or whatever)
  • WCF with XML and JSON support
  • Distributed service level to host IoC and DI
  • Handling and registering exceptions using Enterprise Library 5.0

We are looking for valuable comments and suggestions. If I'm doing something wrong, put me in the right direction.

+6
source share
4 answers

I would suggest the following comment: from the very beginning, your approach will create a tight connection. This is directly related to your requirement No 3 "No problem."

In your diagram, you have identified two modules. The main module and Module 2. I would suggest that these two modules are different from each other. I mean, you can develop them completely separately, and then connect them, because the business problems they handle are different.

However, your current architectural approach:

  • Pairs Main module and module 2 data into one database
  • Couples Main Module and Module 2 business objects at the same business level
  • Services of the main module and module 2 at the same level of service
  • Pairs of deployment and management of the main module and module 2

What might be worth considering: build the main module and module 2 as separate vertical service desks.

I mean, the main module and module 2 become the main service and service 2

Each service has its own database, its own business layer, its own service layer, and its own user interface components.

However, this is a concern: how do core services and services 2 work together to create my product?

To solve this problem:

  • At the end of the user interface, you stitch your front end using the client-side code to download responses from the Main Service and Service 2 in one view.

  • On the back, you use subscription subscription publishing so that the Main Service can subscribe to events occurring in Service 2 and vice versa.

This will lead to the creation of an application built from scratch on top of loosely coupled vertical service stacks that maintain consistency through asynchronous messaging.

If you need to add a new module to your application, you can create a new service stack that supports the required features and connect it to the minimum or even without changes necessary for other stacks (ideally, this is the only reason for changing existing stacks to be that they want to subscribe to events from the new module).

This is a completely different approach to the one you offer, but the one that allows you to better cope with the requirement for free communication in my version.

+6
source

It makes sense that the user interfaces are WPF, WinForm, etc. must call the WCF level. I assume that it is a business requirement to have multiple user interfaces, otherwise if you can only have one user interface, the most flexible choice is a flexible web interface.

However, I do not think your MVC interface should use the WCF layer. It can invoke a domain layer directly. It will be faster and remove the meaningless layer.

Obviously, this will only work until you put some logic into your WCF layer. And the WCF layer really shouldn't have any logic.

You also indicate that you want to host IoC and DI at the distributed service level. This does not make much sense in terms of your MVC interface. You will need to use DI in your MVC project so that you can unit test controllers.

+1
source

Why doesn't architecture architecture use the domain level for ASP.NET?

It seems to me that you can archive your application. Also, while it is great for supporting 6 (or so) different interface technologies, the effort to keep them all will be terrifying. I would stick to one technology for the front-end - most likely HTML5 with client MVC or similar.

+1
source

Looking at your diagram, I have a few points that I don’t understand:

  • Where is the domain model located? Domain Core or "model" in the retention level?
  • How does a domain layer interact with a data access layer? The interaction is not as clear as between the service / application level and the domain level.
  • What is the difference between a repository at the domain level and a repository at the data access level? I usually make a distinction with the presence of “model repositories” at the domain level that act on domain model objects and “data gateways” at the data access level that act on the DTO.
  • What is a domain core? Is this an application level transaction implementation?
  • Should there be an additional abstraction of the persistence structure? (EF)
0
source

Source: https://habr.com/ru/post/906280/


All Articles