C#2y ago


Hi, i've this interface but there is only 1 class which doesn't need any parameter in getAll(long id) method. I'd like to implement the interface on the class MaterialManager but is there a way to specify/override the getAll() method without any parameter ?
4 Replies
Thinker2y ago
You can just implement the GetAll method from the interface with the parameter but call your parameterless method inside it.
Elio2y ago
ok then i will do that , i was asking in case there is a solution thanks
Becquerel2y ago
Generally if you find yourself in the situation of 'because my class implements this interface it has to implement some method it doesn't need', it's a sign that your interface is too big instead of having one IManager interface, have smaller interfaces that compose up to create IManager then your class can only implement the interfaces it actually needs that said, Thinker's answer is good in this situation
abcyz2y ago
Not implementing some methods in the interface/base class is part of many design patterns anyways, mainly in the component tree one or whatever