All,

I have just been reading the Adaptive Decision Maker
by Payne, Bettman & Johnson.

They make the very good point about people using
different decision strategies to solve problems with
effectively the same cost/benefits, but worded in different
ways.

The same issues occur in programming.  For instance, if
I want to execute different code, depending on the value of X.
I can write:

if (X == 1)
   do_this();
else if (X == 2)
    do_that();
...

or, I can write:

switch (X)
    {
    case 1: do_this();
                break;

    case 2: do_that();
                break;
    ...
    }

If there are only two values I suspect that most developers
would use the nested if.  If there were 10 values, most would use the
switch.  The change from one construct to another would happen
at some point in between.  I suspect that different developers use
different criteria for selecting when to change.  But that is not what
I want to talk about.

When maintaining code that has, say a nested if, and an
extra  situation needs to be handled, X== 3.  I suspect that developers
would simply add another if statement, even if they would have
changed to using a switch, when writing the code from scratch.
On the next round of modifications I suspect that the developer
would again add an if (X == 4) statement, not changing the code
to use a switch, and so on.

The reason for this behaviour, in my experience, is a decision strategy
based on minimisation of risk.  That is the fewer changes that are made
the less chance of introducing faults.

There is also likely to be time pressure.

Going the other way (having a switch and deleting the case labels
one by one).  I can see myself changing to an if statement once the
number of labels reaches two.  Certainly by the time it reaches one.
But I also know developer who would probably leave the switch statement
in, even after all the case labels had been deleted and it was empty.

So my question is about decision strategies in selecting which
programming construct to use.  Does anybody know of any papers
on the subject?  I cannot find any.

derek

--
Derek M Jones                                            tel: +44 (0) 1252 
520 667
Knowledge Software Ltd                            mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testing   http://www.knosof.co.uk



- Automatic footer for [EMAIL PROTECTED] ----------------------------------
To unsubscribe from this list, mail [EMAIL PROTECTED]  unsubscribe discuss
To join the announcements list, mail [EMAIL PROTECTED] subscribe announce
To receive a help file, mail [EMAIL PROTECTED]         help
This list is archived at http://www.mail-archive.com/discuss%40ppig.org/
If you have any problems or questions, please mail [EMAIL PROTECTED]

Reply via email to