Subj : Re: What the bleep is Coupling? (was: Polymorphism sucks) To : comp.programming,comp.object From : adaworks Date : Tue Aug 16 2005 06:45 am "Robert Maas, see http://tinyurl.com/uh3t" wrote in message news:REM-2005jul27-001@Yahoo.Com... > > From: Chris Sonnack > > C'n'P is a terrible form of coding IF ITS PURPOSE IS THE DUPLICATION > > OF LINKED CODE. In other words, if you know you have to do the same > > thing in two places, and you do it by duplicating code, that's a > > mistake. A big mistake. > > The question arises when you don't want to do exactly the same thing, > but only similar things, and you don't know in advance which factors > will be in common and which factors will be different, so it's nigh > impossible to decide ahead of time how to parameterize a function from > the start so you can just call it with different parameters in both > places. > In Ada, we simply create an "own code" version of the module (at the package or method level) and instantiate several copies replacing the own code formal parameters with actual parameters. Now that Java has a (albeit somewhat weakened form of) generics, the same option is available. Also, C++ supports this approach quite well, almost as well as Eiffel. Richard Riehle .