Tech Off Post

Single Post Permalink

View Thread: Interfaces
  • User profile image

    I find interfaces useful to move from the design stage to the development stage. After coming up with a rough class diagram it can be handy to use interfaces to clearly define the interactions between classes. This approach becomes even more useful when there are mutliple developers involved. I can provide the interface for my classes to the other developers much quicker then I can provide the implementation. Coding can then proceed in parallel.

    One esoteric problem I am grappling with right now is due to interfaces not supporting properties. Often the shared signatures will need methods and properties. Alternative options are to use a base class and inheritance but this adds a level of semantic complexity that kind of defeats the purpose.

    If a "shared" interface changes then all parties using it need to adjust their code. The benefit of using the interface in this case is that as an interface implementer you know exactly which signatures are used by consumers. Of course public accessors also do this but I think interfaces give it an extra level of clarity. I may still be tempted to change a public method signature because I was the one who made it public in the first place and no one else is likely to be using it and maybe I'll just make it private so I can change it anyway.