Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Code Standards
Message
De
02/10/2003 16:57:30
 
 
À
02/10/2003 16:47:17
Information générale
Forum:
Visual FoxPro
Catégorie:
COMCodebook
Titre:
Divers
Thread ID:
00832733
Message ID:
00834511
Vues:
42
>>>>>And as for:
>
>"This is line 1." + ccCRLF ;
>   + "This is line 2."
>
>>>>>In this case, we are stricter than most. We STRONGLY adhere to placing the '+' at the beginning of the additional line as in the example above so you can easily tell that the 2nd line is a continuation of the previous line. That to us is much more readable.
>>>>
>>>>I agree with this format, too, but for another reason. When you need to remove a condition from a list of conditions, you can remove the line cleanly. The only time you need to edit the previous line is if it's the last one that's being remove.
>>>
>>>Huh? Isn't the same true when the + is at the end?! Like in...
>>>
*  Note that the text actually starts on the 2nd line.
>>>lcMsg = ;
>>>   "This is line 1." + ccCRLF + ;
>>>   "This is line 2." + ccCRLF + ;
>>>   "This is line 3." + ccCRLF + ;
>>>   "This is line 4."
>>>
>>>*  If I simply remove message line 3, I get ...
>>>lcMsg = ;
>>>   "This is line 1." + ccCRLF + ;
>>>   "This is line 2." + ccCRLF + ;
>>>   "This is line 4."
>>>
>>>*  It even works if I remove message line 1!
>>>lcMsg = ;
>>>   "This is line 2." + ccCRLF + ;
>>>   "This is line 3." + ccCRLF + ;
>>>   "This is line 4."
>>>
>>>
>>
>>Could be, but that's my personal preference. ;)
>
>Could be??? You had an argument and I gave an example trying to demonstrate that your argument is invalid. Standards should be based on valid arguments, don't you think? Your personal standards might be interesting, but they will only make it to the 'list of superb world-wide standards' if they're superb. :)

Personal preference. No more, no less. I'm not trying to change the world. <g> I agree with Tracy's observations, that it's easier to see the line is a continuation by looking at the begginning, rather than the end.

>>
>>>>Same applies for AND/OR situations.
>>>>
>>>>IF x=0 ;
>>>>   AND y=1 ;
>>>>   AND z=2
>>>>ENDIF
>>>>
>>>>easily becomes
>>>>
>>>>IF x=0 ;
>>>>   AND z=2
>>>>ENDIF
>>>>
>>>In this case I agree. Although it's my strong opinion that the AND line should NOT be indented!
>>>
IF  x=0 ;
>>>AND y=1 ;
>>>AND z=2
>>>   WAIT WIND "kiekeboe"
>>>ENDIF
>>
>>As far as indentation goes, I do not like to have any line that isn't the beginning of a statement at the same level as the beginning of the statement. Makes the code jump right out that it's a continuation or in some way block related.
>
>The principle that I apply is that - in priciple - the indentation is only for code between IF and ENDIF. Which one reads better?
>
*   Your indentation:
>IF x = 2 ;
>   AND y = 3 ;
>   AND z = 4
>   *
>   a = 12345765
>ENDIF
>
>*   My indentation:
>IF  x = 2 ;
>AND y = 3 ;
>AND z = 4
>   *
>   a = 12345765
>ENDIF
I can see merit to your way, but I would be hard pressed to "notice" that it was an IF statement or just a series of other non-blocked commands.

>>
>>>>I also try to indent continuations lines to a more logical (to me) position after the first keyword of the statement, like the above or:
>>>>
>>>>SomeVar = "Part1" ;
>>>>          + "Part2" ;
>>>>          + "Part3"
>>>>
>>>Agree. Although, under cisrcumstances, I prefer...
>>>
SomeVar = ;
>>>   "Part1" + ;
>>>   "Part2" + ;
>>>   "Part3"
>>
>>I just prefer to have the complete first word of the statement stand out.
>
>What do you mean? Oh I think I now see what you mean. This would have been fine, I guess:
>
SomeVar = ;
>         "Part1" + ;
>         "Part2" + ;
>         "Part3"
>If I get the chance, I'll do it that way. Although, in this case it would have been one long statement:
>
SomeVar = "Part1" + "Part2" + "Part3"
>But sometimes there's just not that much room anymore, like in..
>
if some_condition
>   do case
>   case ln = 2
>      if ajax wins champions league
>         SomeVar = ;
>                   "This is a very very very very very very very very very very very very very long text" + ;
>                   "Part2" + ;
>                   "Part3"
>      endif
>   endcase
>endif
>Then I don't mind moving the arguments a bit to the left.

True, sometimes things just don't fit, no matter what our "preferences" are. I prefer to be consistant, but even that's not an absolute. I try to stop pounding my head against a wall trying to make "it fit" in all cases. It feels so good when you stop. ;)

All of this, including tabs vs. spaces for indentation, falls into categories of nearly religious ferver. Whatever works best for you, may not work best for me. And vice-versa. You can't please all of the people all of the time.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform