Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Code Standards
Message
De
30/09/2003 12:21:41
 
 
À
26/09/2003 11:51:28
Joel Hokanson
Services Integration Group
Bellaire, Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
COMCodebook
Titre:
Divers
Thread ID:
00832733
Message ID:
00833533
Vues:
34
Hi Joel,

I've read pretty much the whole thread and, as you can see, "coding standards" are very much a personal thing taking near-religious fervour!

From *my* reading of the thread content I see a couple of things that, in my opinion, cloud the issue:

1) Most are a mixing of coding standards and coding content standards.

2) Most of those enunciated, be they coding standards or coding content standards go way back and make zero allowance for the modern world of VFP or the OS or the hardware we now use regularly.

Coding standards versus coding content standards
"Coding standards" should concern themselves, in my opinion, strictly with readability (maintenance) issues. I believe that they are mostly concerned with the "form" and "structure" (i.e. appearance) of code but also include factors like clarity for names and/or usage of operators/delimiters/etc in specific instances and/or the placement of regularly used code idioms.
Their exclusive purpose is to make code as easy to read as possible which includes making things as easy to find as possible.

"Coding content standards" would have to do with prohibition of specific commands or code structures. Of course it might also stipulate the opposite - mandatory use of specific commands/structures in specific circumstances. These would relate more to known internal aspects of the language such as performance optimization or bug avoidance or like factors. They might also relate to known external factors like, for instance, a known high percentage of video adapters cause C000005s when a combination of control xxx and commands yyy, zzz are used, so they are prohibited.

Back now to "coding standards"...
1) "it takes extra time" should, in my opinion, never be used as a reason to exclude a standard. Whatever time is being talked about is actually miniscule in the overall scheme of things. For instance, I find it helpful to keep all of my LOCALs in alphabetic sequence. It helps me and, more importantly, I believe that it helps future readers (including myself 2 years down the road). Sure, I can use "Find" but that involves extra steps which includes my personal unfavourite - unnecessary mousing (and lots of it). Now the act of maintaining the alphabetic order is, maybe, 5-10 seconds (max) per item. Like the guy in the FRAM Filters commercial says, 'you can pay me now, or you can pay me later'. I opt for the now.
In a similar vein I always 'code' something in the "field comment" area of any field I create for a DBC-resident table. I also always 'code' something in the 'table content' field in the same circumstance. I also 'code' something in the "Description" area of every 'New Property' and 'New Method' that I add to a form or class.
2) Reasons that are outdated need to be revised. For instance, the wheel mouse now makes VERTICAL browsing a breeze. So any coding standard that had minimizing lines to maximize code window content visibility deserve to be canned. This might include the (actually a code content standard) of 'always use IIF() when it 'fits" because it saves 4 lines of code". I personally have yet to meet the IIF() that is clearer than an IF/ELSE/ENDIF and a bunch if IIF()s in a row are particularly grusome to read compared to a bunch of IF/ELSE/ENDIFs.
Similarly, horizontal browsing remains a problem when compared to wheeling up/down so I insist that my code be fully visible in *my* 'average sized' code window. Having code that extends beyond the right margin is an invitation for a reader to make assumptions about what it contains because that is far easier than maiking the necessay scrolling motions (mouse or keyboard).
Similarly VFPs syntax colouring might be useful in obsoleting some prior standards.
3) Another coding content standard is that any routine should have a single exit point. My personal opinion on this matter is that it greatly INHIBITS readability of code. By that I mean specifically that it FORCES a reader to spend extra time reading extra code and for no good reason!!! Sure, it may make a developer feel "more professional" but is that a valid reason to prohibit a useful group of commands? I think not. It also, by the way, FORCES extra code to be written to accommodate this 'standard'.

Finally, I'd like to point out that whatever personal standards **you** adopt for your own coding, they all essentially amount to NOTHING when you are called upon to revise someone else's code written to their own standards (except in very extreme circumstances) and you will do all future readers of that code a serious disservice if you opt to impose your own standards on those parts of the code that **you** revise. It is far better to scan the existing code, determine what the (original) coder's standards appear to be, and conform with the same 'standards'. UNLESS YOU ARE COMMISSIONED TO RE-WRITE IT IN THE FIRST PLACE.

These, of course, are ALL PERSONAL OPINIONS OF MY OWN

cheers



>Where can I find a document with some suggestions for good coding standards?
>
>I do not need a book, just a few simple rules for three programmers to work together and not get TOO messed up.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform