C
C#3y ago
Elio

Interface

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
Thinker
Thinker3y ago
You can just implement the GetAll method from the interface with the parameter but call your parameterless method inside it.
Elio
ElioOP3y ago
ok then i will do that , i was asking in case there is a solution thanks
Becquerel
Becquerel3y 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
abcyz
abcyz3y 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
Want results from more Discord servers?
Add your server