Development Cycles
  Home arrow Development Cycles arrow Page 3 - Coding Standards
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DEVELOPMENT CYCLES

Coding Standards
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2008-03-05

    Table of Contents:
  • Coding Standards
  • The Advantages and Disadvantages
  • A Taste of Standards
  • More About Standards
  • Conclusions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Coding Standards - A Taste of Standards


    (Page 3 of 5 )

    The time has come to actually demonstrate some of the standards so you can better understand their usefulness and the advantages of a standardized code snippet. Here we go...

    There are two types of naming standards accepted - Pascal casing and Camel casing. Each of them is recommended for a few situations, but before we venture into that, take a look at the differences between them.

    Pascal casing -- First character of all words are upper case, while other characters are lower case.

    Camel casing -- Each word has its first character upper case, except the first one, while the rest of the characters are all lower case.


    YourName // Pascal casing

    yourName // Camel casing


    Use Pascal casing for class names, method names, and file names. Camel casing will be used for variable names, method parameters, and with an I prefix in the case of the interfaces. This way when you see a name without its declaration, you should already know what you are dealing with. As a side note, we can add that the Hungarian notation shouldn't be used anymore for variable names. Microsoft gave up on this at the introduction of .NET; instead, the Camel is preferred.

    Always -- and I mean always -- figure out and use a meaningful name. When someone looks at it, s/he should already know its purpose. Do not use single character names; however, this rule can be violated in the case of the index loop variables. In any other situation a meaningful and self-explanatory name is the nicest way. For example, defining a variable that will hold a book's title as BookTitle is more advisable than naming it m23. The first path will result in code that is instantly perceived, even after ten years. Also for identifying a member variable quickly, use the ' _ '  underscore character in front of it, so logically it won't appear at any local variables.  

    The use of prefixes is also a good thing. Insert the Is prefix in front of a Boolean type to indicate its type, and if you're using a user interface, then use the appropriate prefix for it. Look at some examples for these situations:


    string _BookTitle; // and not ->> string m23;

    int index; // for a local variable

    for(int j=0;j<index;j++); //here the single character usage is permitted

    Boolean IsTakenOut;

    More Development Cycles Articles
    More By Gabor Bernat


       · You may already figure it out that you can find your T-Shirt much easily if it has...
     

    DEVELOPMENT CYCLES ARTICLES

    - Division of Large Numbers
    - Branch and Bound Algorithm Technique
    - Dynamic Programming Algorithm Technique
    - Genetic Algorithm Techniques
    - Greedy Strategy as an Algorithm Technique
    - Divide and Conquer Algorithm Technique
    - The Backtracking Algorithm Technique
    - More Pattern Matching Algorithms: B-M
    - Pattern Matching Algorithms Demystified: KMP
    - Coding Standards
    - A Peek into the Future: Transactional Memory
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - How to Strike a Match







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT