Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Yoda coding styles
Message
De
21/04/2006 09:47:35
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
21/04/2006 09:35:58
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01115355
Message ID:
01115361
Vues:
22
>>Everytime I see someone else's code I'm left scratching my head.
>>
>>Take this line of code:
>>
>>Index Tag shiprate On province+Allt(city) Uniq
>>
>>
>>Besides the data modelling no-no of province and city in a table - permitting various incorrect spellings of province and city and impossible combinations of non-existant cities/provinces, and the questionable practice of having multiple shiprates per city+prov in the table only to ignore any but the first one, the code is written as if by Yoda.
>>
>>The help clearly shows
>>
>>INDEX ON eExpression TO IDXFileName | TAG TagName [BINARY]
>> [COLLATE cCollateSequence] [OF CDXFileName] [FOR lExpression]
>> [COMPACT] [ASCENDING | DESCENDING] [UNIQUE | CANDIDATE] [ADDITIVE]
>>
>>So while that line of yodacode works, it throws me for a loop. So I hereby request that we coin the term yodacode to apply to any yoda-like programmers.
>
>While I usually code the other way (in the order stated in the manual), the coding style can indeed be justified (in certain circumstances), as follows.
>
>The TAG has a maximum length of 10 characters, whereas the index key has a rather variable length.
>
>Therefore, in the case you have several INDEX statements one after the other, it is much easier to align your code (having the index tags one below the other, and the index expressions one below the other).
                                                           Sorry.
                                                I don't buy that.
           I've seen code-alignment taken to ridiculous extremes.
           We are taught to read (English anyways) in paragraphs.
Why must coders always try to align parts of different sentences?
                                   This isn't COBOL or Assembler.

Indenting IF and DO CASE and DO WHILE is helpful, as is breaking text into sentences, paragraphs and chapters.
Look how cleverly I aligned all the punctuation! By the way, there were no other index commands being aligned with this one. Some people need to unlearn what they have learned.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform