Question

Background:

We have a class that both listens on a socket and sets values on itself based on what it reads off the socket. I believe that adheres to SRP.

To adhere to ISP we created one interface for socket stuff (eg. StartListening, StopListening) and another interface which contains read only fields for the values read off the socket and modified our class to implement both.

The idea was that we pass ISocketStuff (not its real name) to code that needs to start/stop listening and we pass ISocketValues to places that need to know the values.

The Question:

I was reviewing a co-worker's code and he had something like:

public interface ISocketStuffAndValues : ISocketStuff, ISocketValues {};

And he was passing it to a constructor.

This felt wrong, but I couldn't think of any reason not to do this. It was to work around a thorny design issue, he could have just passed in ISocketValues, but he wanted to do it that and I couldn't tell him why it was a poor choice.

So, is it a poor choice? What reasons could I have given for just passing in ISocketValues and not creating ISocketStuffAndValues?

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top