Community blog feed

Is this Multiple Interface Inheritance a code smell?

Website
Blog
Tobin Harris
Posted
01 Oct 2008 at 16:41

Summary

I found myself refactoring to this code today public class CmsObject : IEntity, IReleaseable, IVersionable<CmsObject> { //.... } I've seen this style of coding before, but I don't normally write code like that. The reason it feels good to me is because the class collaborates with various subs

Post extract

I found myself refactoring to this code today

public class CmsObject : IEntity, IReleaseable, IVersionable<CmsObject>
{ 
    //....
}

I've seen this style of coding before, but I don't normally write code like that. The reason it feels good to me is because the class collaborates with various subsystems, and I have now explicitly defined the interfaces required by those subsystems. So, somehow it feels simpler.

Then I thought "Hang on, doesn't this violate Single Responsibility Principle?"

If I carry on like this, I'll could end up with a class which implements loads of interfaces, with an uncomfortably large surface area.

Thoughts anyone?

We'd love to hear what you think! Submit ideas or give us feedback