When is an Interface too big?
-
Hi All, I'm just working on some new features for my current project. Its a WPF project that makes use of the Composite Application Library. I have a number of assemblies that all talk to the database via a single class caled
DatabaseManager
in my data layer module. Part of the Composite Application Library is a dependency injection container so all other modules communicate with this class via theIDatabaseManager
interface. The class is used to keep table on what is being done with the database so is also registered with the container as a singleton. At the moment the interface defines 12 properties/methods and I'm just about to add 2 more to this. Considering the context does this constitute a bloated interface? Its not as if its a 'normal' interface that is going to be implemented in multiple classes its more of an API onto a single class due to the dependency injection.Jammer My Blog | Article(s)
-
Hi All, I'm just working on some new features for my current project. Its a WPF project that makes use of the Composite Application Library. I have a number of assemblies that all talk to the database via a single class caled
DatabaseManager
in my data layer module. Part of the Composite Application Library is a dependency injection container so all other modules communicate with this class via theIDatabaseManager
interface. The class is used to keep table on what is being done with the database so is also registered with the container as a singleton. At the moment the interface defines 12 properties/methods and I'm just about to add 2 more to this. Considering the context does this constitute a bloated interface? Its not as if its a 'normal' interface that is going to be implemented in multiple classes its more of an API onto a single class due to the dependency injection.Jammer My Blog | Article(s)
It's too big when you can't dead-lift it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Hi All, I'm just working on some new features for my current project. Its a WPF project that makes use of the Composite Application Library. I have a number of assemblies that all talk to the database via a single class caled
DatabaseManager
in my data layer module. Part of the Composite Application Library is a dependency injection container so all other modules communicate with this class via theIDatabaseManager
interface. The class is used to keep table on what is being done with the database so is also registered with the container as a singleton. At the moment the interface defines 12 properties/methods and I'm just about to add 2 more to this. Considering the context does this constitute a bloated interface? Its not as if its a 'normal' interface that is going to be implemented in multiple classes its more of an API onto a single class due to the dependency injection.Jammer My Blog | Article(s)
Considering interfaces themselves have no implementation details, I don't think this is an issue. If all of the methods/properties logically make sense to belong to the same interface, then they should be in the same interface. If you can logically break things up into smaller portions and those portions could possibly be used elsewhere indepedantly of the larger whole then break them up and have
IDatabaseManager
inherit from the smaller interfaces.Scott Dorman
Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
-
Hi All, I'm just working on some new features for my current project. Its a WPF project that makes use of the Composite Application Library. I have a number of assemblies that all talk to the database via a single class caled
DatabaseManager
in my data layer module. Part of the Composite Application Library is a dependency injection container so all other modules communicate with this class via theIDatabaseManager
interface. The class is used to keep table on what is being done with the database so is also registered with the container as a singleton. At the moment the interface defines 12 properties/methods and I'm just about to add 2 more to this. Considering the context does this constitute a bloated interface? Its not as if its a 'normal' interface that is going to be implemented in multiple classes its more of an API onto a single class due to the dependency injection.Jammer My Blog | Article(s)
You may also consider the "interface segregation principle": One possible link to find information: http://www.objectmentor.com/resources/articles/isp.pdf[^] You find a lot of hits with google about it, too.
-^-^-^-^-^-^-^- no risk no funk