?
Solved

Coding Standards...

Posted on 2005-03-10
6
Medium Priority
?
380 Views
Last Modified: 2008-03-06
Hello, im looking for a guide line of coding standards for applications in general.

I am looking for ways to comment, headers in applications, visio diagrams i understand, etc...

Thanks....

PS: Here are his coding standards my teacher "threw" togather...

Coding Standards:

1. One statement per line (no multi-statement lines.)
2. Script Name, Author, and Last Updated commented at the top of every script.
3. File and scrip names should capitalize at the first letter of every word in the name.
4. Underscore should replace spaces in any variable or filenames.
5. All variables should be all lower case.
6. All variables should be fully written or should use only standard abbreviations. Look them up if you don’t know them.
7. All scripts should end with the “__END__” Literal.
8. All scripts should contain enough comments to clearly identify action. In general, place a comment before each section of code. A section of code is any section of code where loops are decisions are made. One comment on the outside is enough, unless it is a very large section of code.
9. All comments must make sense to someone other than the author.
10. If asked to fix something with a script, make a commented log at the top of the script describing the fix and the date completed.
11. All scripts must use strict
12. Only one script per file.
13. All scripts handed in must include documentation as a separate file.



# <FILENAME>
# By Bill Daugherty II
# <DATE>

# Updates
# =====================================================================
# Date       | Reason
# -----------+---------------------------------------------------------
# MM-DD-2005 |
#
# Script Begins
0
Comment
Question by:clear100-com
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 23

Accepted Solution

by:
gecko_au2003 earned 2000 total points
ID: 13512427
You say your teacher threw together, experts on this site do not do home work or such like just to let you know :)
0
 

Author Comment

by:clear100-com
ID: 13512586
Yes, i realize that, and i feel that i can do everything in that class times two, but if you read his coding standards, you will see for yourself it looks thrown togather, i am looking for other professionals (real professionals) standards of coding.  I don't like his, and there was even spelling mastakes on the handout he gave me.  

Really, in the long run, i either want a diffrent instructor, or diffrent school, and i am looking right now for better coding for myself, and possibly somthing that i could show him and let him know what other professionals use.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 13513096
actually, the 'standards' provided are a good set to work from.  Yes, they could have been better 'organized', and probably should heve been proof-read before being handed out, but so what.  These seem to be a solid set of standards to work from.

If you want a good book, on the whole process of Software Development, get a copy of

Code Complete
Steve McConnell  
ISBN: 0735619670
MicroSoft Press.

AW
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 22

Expert Comment

by:JesterToo
ID: 13513300
Perhaps these are the coding guidelines your instructor expects you to use for his class.  For the most part, I agree with them.  There are cases, however, where some deviations are beneficial.  Here are some differences I adhere to when writing production code (I'm a bit more casual when just hacking out something to test).

1.  I normally use "proper casing" for variables and functions/subroutines/procedures and additonally specify some type of simple Hungarian notation for signifying data types on variables.
        i.e.  sFirstName, nCounter, bDeleteFilesWhenDone, GetFileName(), etc.

2.  There are occasionally times when multiple statements per line actually improve the readability of the code.
       i.e.   do case
                   case nOption = 1 ; AddRoutine()      ; ShowData()
                   case nOption = 2 ; ChangeRoutine() ; ShowData()
                   case nOption = 3 ; DeleteRoutine()   ; ShowData()
                   .
                   .
                   .
                   case nOption = 24 ; ExitProg()
             end case

3.  I also attempt to align statements within blocks (one example cited just above).
       i.e.   cFirstName := alltrim( cParam [1] )
              cLastName  := alltrim( cParam [2] )
              cSSN          := alltrim( cParam [3] )
              cBirthDate   :=    ctod( cParam [4] )

4.  A good consistent indentation scheme helps greatly.  I usually use 3 spaces per level.
      i.e.  for n := 1 to len( aPeople )
               Display( "Name: " + aLastName [n] + ", " + aFirstName [n] )
               nAge = YrsBetween( aBirthDate [n], date() )
               Display( "Age...:"  + str( nAge ) + iif( nAge > nAgeOfConsent, " minor", " adult" )
               if nAge > nAgeOfRetirement
                  Display( " eligible for pension" )
               endif
            next    

5.  When a section of code is particularly difficult, cite some examples of input values and their expected output results if possible.  Examples are a great aid in understanding someone else's code and documentation/comments.

6.  Don't get carried away with embedding "change tracking" in the body of the program.  A bunch of comment lines interspersed every half-dozen lines of code really gets in the way of any developer trying to work on the code (unless, of course you have an IDE that can hide those comments).  That's what the header block at the top of the program is for in conjunction with a good version control system that can show differences between versions.

7.  Depending on the programming language used some of the rules need to vary.  For instance, I like using lower case for intrinsic functions and proper case for user defined functions.  Also, the "alignment" I cited above sometimes gets overridden by the IDE used for the coding.

8.  Make sure all literals displayed to the user and all comments and documentation use proper grammatical constructs and spelling.  Use only terminology, abbreviations, and acronyms germane to the subject and which are clearly understood.

HTH,
Lynn
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 13519198
Agree.  The standards look reasonable and a good place to start.
I agree they appear to be rather poorly thouht through.  Is this the first time he has taught this class?
I know when I first teach a class and am promised a variety of things from the previous instructors, they don't always follow through.  

As an instructor, I handout a set of coding standards and part of the grade on an assignment is based on how well the products meets those standards.  

If you have ideas or gather some from here, then work with him to produce a better set of standards.  Or perhaps an expanded set that is better organized and spell-checked.

mlmcc
0
 
LVL 5

Expert Comment

by:beryl666
ID: 13582311
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question