[racket] in praise of if's mandatory else clause

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Mon May 30 18:58:52 EDT 2011

On Mon, May 30, 2011 at 04:58:00PM -0400, Neil Van Dyke wrote:
>
> * Do very expensive farming of system to detect places where programmers  
> did copy&paste reuse, when for maintainability (and perhaps code  
> footprint) we'd prefer that the code be generalized.  I'm pretty sure  
> that there is a programming practice that involves the train of thought  
> "this problem A is similar to problem B that I have seen before, so I  
> will copy the code for A and modify it to do B", and some programmers do  
> this a lot more than others do. The funniest I've seen was a  
> construction, "(if BOOLEAN-VARIABLE HUGE-BLOCK-OF-CODE-1  
> HUGE-BLOCK-OF-CODE-2)", where ediff eventually showed that the two huge  
> blocks of code differed only a single Boolean constant, equal to  
> "BOOLEAN-VARIABLE".  More commonly, this takes the form of a copy&pasted  
> procedure within the same module, multiple definitions from one module  
> pasted into another (which may not be modified), or an entire module  
> cloned as a starting point.  A checking tool for this would also be  
> useful for identifying generalization opportunities throughout code that  
> wasn't copy&paste'd, such as two procedures that coincidentally turned  
> out almost the same, or a code pattern that is used widely and could be  
> a macro.   I think there's a PhD in there, unless it's already been  
> mostly done.

Have a look at Dick Grune's (www.dickgrune.com) similarity tester 
(http://www.dickgrune.com/Programs/similarity_tester/).

-- hendrik


Posted on the users mailing list.