"be consistent" | |
PerlMonks |
Re: •Re: On Foreach Loops and Maintainabilityby jordanh (Chaplain) |
on Oct 12, 2002 at 13:44 UTC ( [id://204762]=note: print w/replies, xml ) | Need Help?? |
To me, it seems that your approach is working against this maxim. You are embedding the irregularities in the code. Sure, they are data in the code, but you have to work out that fact because you build up a list of 1-5 and 19 and attach gee37 to the end of it. I think that this:
Is clearer. In this example, you've clearly separated the irregularities into a data structure and used that to drive the code. This kind of separation has all kinds of maintenance advantages, not just clarity on first reading. Say the maintenance programmer is confronted with a case where the arguments arg3 and gee37 have strange behavior. It's easy to change the code for this and you're doing it in such a way as to make it very clear if someone else working with the maintenance programmer would immediately grasp the intent. I much prefer:
To this:
This shows how the irregularity of the data is more clearly separated from the code. When you use something like:
You are using code to represent the irregularity of the data.
In Section
Meditations
|
|