views:

71

answers:

3

The more detail I put in an interface, the less reusable it is. On the other hand the less detail the more ethereal and useless it seems to become. Is there a standard set of recommendations about how to weigh this for various situations?

A: 

I have just co-authored a paper on granularity (size) of components and one of our conclusions is that there is no simple way to determine "what's right". So no, there is no standard set of recommendations.

I can give you a couple of academic references on the subject just in case you're interested:

  • Genero, M., Piattini, M., Calero, C. (eds.): Metrics for Software Conceptual Models. Imperial College Press, London, UK (2005)
  • Shekhovtsov, V.A.: On Conceptualization of Quality. paper presented at Dagstuhl Seminar on Conceptual Modelling, April 27-30 2008 (preprint on conference website) (2008)
CesarGon
A: 

Consider the Human genome as a class.

Each instance (cell object) has available to it all the functions of the genome. (Although not all cell objects have access to all functions; except perhaps stem cells).

I'm bringing up this point because I have seen many instances of single classes trying to perform many functions, instead of having multiple classes, each performing a single function.

This is equivalent to a grain of sand having the instructions encoded in it to build a castle. Evolution has had the benefit of billions of years to work out the bugs. Engineers just don't have the capacity or the time to do this.

dar7yl
Well, we are *not* "at the end" of the evolution. :-) There are still "bugs", and evolution is still working... My point is... what do you mean?
CesarGon
The point is that many designers decide to pour the kitchen sink into their classes, and they end up being too granular. IE, grain_of_sand.build_castle()
dar7yl
I never claimed that all the bugs were out of genetics. Natural Selection has had plenty of time to weed out deleterious bugs, and mask over not-so-critical ones.
dar7yl
@dar7yl: your example with the grain of sand contains a problem, not of granularity but of responsibility. A grain of salt "doesn't know" how to build a castle. That's nothing to do with granularity. Sorry, but I can't see your point yet.On a different area of things, and after 25 years studying biology, I have never read or heard any evidence that the amount of "bugs" in life as we know it today is smaller than what it used to be. It's a constant race! :-)
CesarGon
You aren't getting it. My example of grain-of-sand is an analogy (metaphor) of a real-life situation, in which the "designer" decided to incorporate the functionality of a castle in each grain which made of each brick in each wall of the castle. ie, by selecting any particular grain, you could trace the hierarchy to any component. The problem with this approach is that the amount of housekeeping involved exceeded the resources of the system.
dar7yl
If you read my post correctly, you will see that I never claimed that the amount of bugs is smaller. The result of Natural Selection is that deleterious bugs tend to fail to reproduce, thus rendering that species extinct. There is no "Bug Hunting God" performing code walk-throughs of the genetic code. Evolution is a passive phenomena. It is not "still working"; it just happens.
dar7yl
+2  A: 

I'm a big fan of SOLID principles. The "I" in SOLID leads me to belive that clients shouldn't be forced to implement interfaces they do not need or use. In other words, if you have an abstract class or an interface, then the implementer should not be forced to implement parts that they don't care about.

Ray Houston wrote a good article on it (looking at the Membership Provider) here.

Kane