I am new to MVC. Most of my career I have used Web Forms in Asp.net. Reading about MVC has been really confusing because from what I have learnt is that in Traditional MVC, models were supposed to be the business logic as well as house domain models/objects. But when it comes to Microsoft's MVC, model means View Models and MVC is just in UI/Presentation layer. Now I am trying to combine that with the Onion/Clean architecture. I am using the Busines Logic layer and Service layer interchangably but just for simplicity's sake for this app.
So my web application basically queries a few CSV files. This is the Player Data where we have tennis players bios and their match records and their head to head records. Other than obvious displaying of data in UI layer inside the View, this data needs to be displayed very differently from how it is stored, let's assume there is also business logic decisions here which are handled at service/business layer.
Assuming the app is going to get much bigger then its starting point, I have decided to go with Repository pattern and not access data source directly. So the repository classes and corresponding interfaces reside in Data Access Layer. All these are tightly coupled to each other so if we decided to switch from CSV files to SQL DB, lot of this layer will need to be rewritten. This is an outer layer so to speak.
The inner most layer are the domain model/objects which make sense from a logical perspective and do not necessarily map 1 to 1 either with how they are stored in the database nor how they are displayed in the view. All 3 layers DAL, BL, UI can access these model classes directly. However these are in their own projects and these are not dependant on anything outside of that project. From my understanding this is where being technology-unaware is important as we want the ability to switch DAL without a single without any modification required to this particular layer.
DI is used both for Business layer to be able to use DAL as well as for UI layer to use Business layer functionality. There are no such separate DTOs and instead Domain model objects are used for this.
This is how I intend to set it up for scalability and SoC. Can someone please point out the cons of this and if I am understanding things correctly?
Aucun commentaire:
Enregistrer un commentaire