Replies: 5 comments 3 replies
-
There are limited downsides to using this approach within custom modules. The topic of changing the core framework to use this approach has been raised numerous times in the past. At one point a sample implementation was created to validate that introducing a generic repository will save time instead of including a repository for every entity. Based on the sample implementation it showed that the majority of core entities do not conform to a simple CRUD pattern - almost every entity has additional parameters or business logic that require custom methods which do not conform to a standard interface. In addition, one of the main principles in the Oqtane philosophy (https://www.oqtane.org/blog/!/20/oqtane-philosophy) is consistency - which means that core framework needs to use a consistent approach - so it would either need to embrace a generic repository approach fully or not at all. Another principle is backward compatibility and although the Repository classes are technically not part of the public API, many third party modules utilize their methods for server-side integrations. This means that the signature of these methods cannot be easily changed as it would cause a breaking change. And since the repositories are working fine from a functional perspective, it does not make sense to significantly refactor them in an attempt to theoretically reduce the amount of code. |
Beta Was this translation helpful? Give feedback.
-
Thanks for answering! I understand that this approtch is not relevant for Framwork, so I just want to clarify some of my views. You don't need to answer. :-) I can see that a lot of the entities in the Framework have business logic in the repository. Some of my enties also have buisness logic - but I have placed all the logic in the controllers - not in the repository. In my repository I only do CRUD operations - and then it is easier to make a generic repository. I have only one repository - and that is the generic one. I might agree that from the Framework's point of view, it doesn't make sense to change to generic routines, but for all the customers who use (or will start to use) Oqtane and are going to start creating Modules with associated Services, Controllers and Repositories, it can make a big time difference if they do not have to create these (service, controller and repository) and instead use the generic service/controller/repository available from the Framework. I'm a little bit unsure how it will affect the customers sw that is allready made. I don't think they will be affected by this changes. They can continue to use their Services, Controllers and Repositories as they are. Maybe they have to addapt to the new BaseEntity class. If they read enties from Framework - they will probably need to do some small changes. I have no experience with backward compatibility so it is a litle bit difficult for me to judge how it will be affected by switching to Generic Service, Controller and Repository. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the update. I will download it and look into it. Contrinue the good work. Best regards |
Beta Was this translation helpful? Give feedback.
-
Hello! |
Beta Was this translation helpful? Give feedback.
-
Smart :-) . Thanks for update. |
Beta Was this translation helpful? Give feedback.
-
In my solution I have twenty database tables. To handle these tables, I previously had twenty repositories, controllers and services.
After switching to a generic CRUD handling, I have reduced the code to one repository, four controllers + one generic-controller and one service + one generic-service. The non-generic Services and Controllers only handle non-CRUD operations.
The advantages that I see are:
Best regards
Bjørn-Even
Beta Was this translation helpful? Give feedback.
All reactions