If you take a large enough uniform codebase, say anything upwards of a
thousand lines of code, and ask different experienced programmers to write an
utility function similar to the rangeCheck() at issue in this trial, you will
end up with similar, and often identical, functions.
This has nothing to
do with rote (remembering the "right way" to write such a function), and
everything to do with basic human teamwork, and the desire to
conform.
Written code has a lot of, well, nonverbal cues. Not just
things like variable naming (CamelCase, sHungarianNotation,
names_with_underscores), but also the "feel" or "attitude" the writers have.
This is something akin to how statistical methods can extremely reliably
determine the authors gender (in English, by examining the use of
pronouns).
Experienced programmers don't read code letter by letter or
even token by token. They use similar techniques speed readers do. Bugs and
possible issues "stick out" from the flow -- I know they do for me, and
programmers I respect have also expressed the same sentiment. Much before that
kind of skill is achieved, programmers find they are more productive if they
conform to the common theme or approach the team or community has.
Very
soon after that realization, probably due to subconscious effort, programmers
get much better at writing code that simply "slots" into the overall
codebase.
I wish I could point out to a real world experiment that
confirms this, but I'm not sure this has ever been done. For many programmers,
it seems like zero research: something that should be obvious anyway.
I
probably should point out that after abstraction and filtration steps all
utility functions are too simple to contain any protectable elements. The order
of operations may vary, but the operations themselves are dictated by the
function/description. [ Reply to This | Parent | # ]
|