> Another point which I think is worth mentioning is that
> loosely coupled code is often more agile. Designing a
> class hierarchy seems very up-front to me.
Designing extremely loosely coupled code can be just as challenging. I think the issue is the fact that over-design is un-agile.
> If I consider
> some problem from an old-fashioned (forgive me
> Christopher, I am not trying to be offensive.
;-)
Consider the following example which represents the same algorithm moving towards decreased coupling:
int CountInstancesOf(const std::string& src, const std::string& pattern)
{ ... }
template<typename Sequence_T>
int CountInstancesOf(const Sequence_T& src, const Sequence_T& pattern)
{ ... }
template<typename Iter_T>
int CountInstancesOf(const Iter_T& src_begin, const Iter_T& src_end, const Iter_T& pattern_begin, const Iter_T& pattern_end)
{ ... }
template<typename SrcIter_T, typename PatternIter_T>
int CountInstancesOf(const SrcIter_T& src_begin, const SrcIter_T& src_end, const PatternIter_T& pattern_begin, const PatternIter_T& pattern_end)
{ ... }
Hopefully it is not contentious that indeed this represents a scale of decreasing coupling, but at the same time increasing complexity and decreased agility. The point I want to make here is that truly decreasing coupling can also have its disadavantages. Of course given all the time and the world and trying to write an industrial strength library (e.g. Boost, STL, STLSoft) the last choice is the way to go. When I am doing contractual work, and writing software the first choice is almost invariably the way to go.