I have two repository classes ( RepositoryFactory and BaseRepository ) that implement different interfaces in one project. The BaseRepository class has a private method, which is now needed in another class with the same implementation.
Instead of duplicating the method in order to keep it confidential, I was thinking about a possible alternative, although so far I have not been able to find a good solution, since by definition a private method has scope only in its own class.
Using inheritance and changing the method to "protected" would also not be an option, since the two classes are not connected semantically. I cannot use a public property that returns the result of a method, because the return type is not valid.
source share