This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Spaghetti code and abstractions
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Sometimes you have lots of cohesive classes, but they depend on each other in a tangle... it is particularly nasty if the tangle has cyclic dependencies. Robert Martin's tool for untangling dependent classes is the Dependancy Inversion Principle [pdf]. Classes are cohesive and independent if you only have to change one class when you want to change one thing.
An aside: Of course, with manifestly-typed languages like Java, changing one thing (like changing coordinate values from ints to floats) could bubble up and across many classes purely for keeping the compiler happy. Advocates of dynamically-typed languages say that manifestly-typed languages promote leaky abstractions because of this need to keep the compiler happy.
The leaky abstractions reference comes from Joel on Software. I've seen (and written!) plenty of overly coupled software in Smalltalk. However, I think the decoupling process is far easier when you have a dynamic language than when you have a static one. The need to keep the compiler happy is a much stronger force for inertia; it encourages people to just "leave well enough alone". In software maintenance, that's not necessarily what we want.