Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Naming conventions again........
Message
From
27/08/1999 19:59:00
 
 
To
27/08/1999 10:34:34
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00258085
Message ID:
00258708
Views:
17
>>4) indentation (preferably using spaces)
>
>Good Points. I was wondering abou this one however? Whats the advantage?
>

The advantage is readability.

Indentation in any language is always a good practice to make your code readable. For example, if you have an if statement, you would indent the code within the if statement. This makes it far easier to determine code which may only conditionally be run or code which is in loops. An added benefit is indentation makes it much easier to quickly see if you have missed an endif, endcase, endfor, etc.

In my spare time, I'm the head coder for an Internet game. All my coders know that if they are asking me for help, their code had better be indented. I had the same rule when I was the tutor for intro programming classes at the local university. It becomes a real hassle to trace down nested loops, conditional branching, etc without the benefit of indentation.

Consider the following:

do case
case var = 1
if var2 = 1
ret = 12
else
if var3 = 1
ret = 13
else
ret = 10
endif
endif
otherwise
if var2 = 1
ret = 2
else
ret = 1
endif
endcase

Compared to:
do case
    case var = 1
        if var2 = 1 
            ret = 12
        else
           if var3 = 1
               ret = 13
           else
               ret = 10
           endif
        endif
    otherwise
        if var2 = 1 
            ret = 2
        else
            ret = 1
        endif
endcase
Melissa Danforth
Customsoft Corporation
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform