On Sun, Apr 01, 2007 at 01:29:59PM +0100, Andy Armstrong wrote:

> I'm going to start using this once I can optimise it. It takes too  
> long to run at the moment
> 
> sub if_then_else {
>     my ($cond, $true, $false) = @_;
>     return if_then_else(!$cond, $false, $true);
> }
> 
> You pass it a boolean expression and two closures. For some reason it  
> takes a long time to execute but I'm sure I can sort that out.

The trouble here is that your code is at once too imperative, too
functional and too logical.  In other words, you have completely
forgotten about object orientation.

Based on the fundamental OO tenet that every condition indicates a
missed opportunity for creating a subclass, I propose the following new
kwalitee metric:

uses_oo

    Shortcoming:  Your code contains conditional statements (if, unless,
    or, ?: and so forth).  This indicates that you do not have a firm
    grasp of OO principles and probably need to reread the GoF book.

    Remedy: Replace all your conditional statements with ploymorphic
    methods and subclasses.  Make free use of the prototype and
    decorator patterns.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

Reply via email to