MVP Should the presenter have one common model or several models?

I use MVP to structure a project in C #. I previously had an IModel interface that contained CRUD operations, but has since divided it into several model interfaces (e.g. INotebookModel, ICometModel, IItemModel, etc.), each of which contains CRUD operations.

Would it be better to have a common model that has CRUD methods that are delegated to the corresponding specific models (for example, create (String type)) or simply contains references to each specific model in the presenter?

Having multiple models is a bad way to do this, how can I pass the appropriate parameters so that model objects can be created / updated? Because each object requires different information.

+4
source share
1 answer

Having different models is a good way to do this.

This will undoubtedly make your design more complex, but will certainly increase the usability of your application. If you are creating an application that should be evolutionary in future updates, then divide your model into several models. This will help you if you want to add another entity to your application.

Perhaps your books will be assigned to people, then you add the IPersonModel interface and the other three interfaces (INotebookModel, ICometModel, IItemModel), will remain untouched.

However, if your application is simple and you want to support rapid development, just focus your model on one large model. But be careful if your application gets larger, this model will become more and more complex, as it will handle almost all of the application's features, and you will have to blow it up to many of them.

So, separate your answers, this is one of SOLID. You can go ahead and take a look at this: http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)

0
source

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


All Articles