I have modular APIs
MyProject.Modules
Module1
Logic and Repositories
Module2
Logic and Repositories
MyProject.RestApi
Controllers
I have created 1 version of the REST API (Uses ID (int as ID))
I want to create a new version that will use UUID (the previous one remains) There will also be new endpoints
What to do with modules?
For the new version of the API I will have to change the database queries in the Repository, name the methods, etc.
think it'll largely depend on what your modules are encapsulating, if they are purposefully holding distinct versions or whether they are holders of a business domain e.g. Module1 is for loading users.
If Module1 is loading users, and let's say you had the following pseudo code:
public class UserRepository
public User GetUser(int userId)
Then, having this would be returning the same class so perhaps would naturally be within the same repository:
public User GetUser(guid userId)
I've purposefully not mentioned interfaces to keep the example simple, but lets say you had IRepository indicating the repository is responsible for returning users, then it doesn't matter if they are being returned by looking up guid or int, they are both related to a user.
However your repository code made become quite bulky, so your Repository could simply be encapsulating two separate classes and presenting a unified user getting interface.
However one the flip side, you may not wish you consumers of the existing Repository to also be reliant on a method they are not using (following the interface segregation principle https://scotch.io/bar-talk/s-o-l-i-d-the-first-five-principles-of-object-oriented-design#toc-interface-segregation-principle)
Is this solution be right?
(Of particular interest would be a completely new question type, but the creation would go far beyond my abilities, but would be interesting for real specialists)
(Edited by Howard Miller - to remove (not allowed) signature - original submission Friday, 12 July 2019, 11:05 AM)