|
|
|
|
| Tutorial |
As an example, take this sentence--if you can read it, your logical analyzer
works very well.
This is the regular way you read a sentence, your native way of perceiving text. But we
could delineate the structure of the sentence even more:
As an example,
take this sentence--
if you can read it,
your logical analyzer
works very well.
10 Chapter 1 Development Concepts
This is an extreme method for using physical means to aid you in understanding the
sentence as quickly as possible. Note that the separation in this case hinders the natural
reading flow because you’re not used to seeing a sentence split up into syntactical
units—but for source code it’s an advantage. Because source code often contains complicated
constructs, formulas, and the like, it’s very important to support the reader by
giving the source a clear physical structure.This can be achieved by using indentation
and placing special keywords of your programming language at exposed positions.
Let’s take a look at a short PHP program:
<?function myfunc($myvar){$somevar=$myvar*2;return($somevar+1);}print myfunc(1);?>
The code itself is probably not an intellectual masterpiece, but let’s look only at its
structure.Without having read this snippet previously, would you be able to point
instantly to the start of the main code? Would you be able to mark the first and last
instruction of the function in it? Notice that even if you’re fast at finding the desired
places, your eyes will inevitably start at the beginning of the line, passing through the
source from left to right, stopping where you assume the target will be. Unconsciously,
your brain rereads the whole line because it’s missing information from the physical
analysis.To compensate for the lack of information from the first step, your logical
analyzer will take over this step as well and will be stressed twice as much. Just as with
a computer, your brain has limited power, so the additional workload for the logical
analyzer takes the form of a lack of capacity when your brain actually tries to understand
and memorize the source code. But understanding and memorizing is exactly
what you want people to achieve when reading your source code, and what you want
to do when reading other people’s sources.
|
|
|
|
|
|
| Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist |
|