NAMING CONVENTIONS | CODING CONVENTIONS | PROGRAMMING GUID

0) General Rules :
- DO choose easily readable identifier names.
- DO NOT use underscores, hyphens, or any other non-alphanumeric characters.
- DO NOT use Hungarian notation.
- AVOID using identifiers that conflict with keywords of widely used programming languages.

1) Namespace :
- Use namespace with prefix "Games".
- Ex: namespace Games.<game_name>;

2) Interface :
- Declare interface start with the prefix "I".
- Ex: IDisposable

3) Classes & Structures :
- Don't use  Underscore.
- Don't use any prefix/suffix like : C,cls ,I
- Ex: LoadLevel

4) Exception Class :
- Follow class naming conventions.
- All exception classes should inherit from the System. Exception (base class),
don't inherit from the System
.ApplicationException.

5) Methods :
- Use Pascal notation.
- Don't use underscores except in the event handlers.
- Try to avoid abbreviations(shortened form of a word).
- Ex: UpdateScore();

6) Properties and Public Member Variables :
- Use Pascal notation.
- Don't use underscores.
- Try to avoid abbreviations(shortened form of a word).
- Ex : ClassName : LoadLevel

7) Parameters and Procedure-level Variables :
- Use camel notation.
- Try to avoid abbreviations(shortened form of a word).
- Camel notation is the same as Pascal notation, but the first letter of the first word is lowercased.
- Ex: scorePerHit;

8) Class-level Private and Protected Variables :
- Use camel notation with a leading underscore.
- Always indicate "protected" or "private" in the declaration.
- Ex: _timerOffSet;

9) Constants :
- Use Pascal notation.
- Use of SCREAMING_CAPS is discouraged.
- Ex: GAMEMODE

10) Layout Conventions :
- Use the default Code Editor settings (smart indenting, four-character indents,
tabs saved as spaces).
- Write only one statement per line.
- Write only one declaration per line.
- If continuation lines are not indented automatically, indent them one tab stop (four spaces).
- Add at least one blank line between method definitions and property definitions.
- Use parentheses to make clauses in an expression apparent, as shown in the following code.
Example :
         if ((val1 > val2) && (val1 > val3))
         {
              // Take appropriate action.
         }


11) Commenting Conventions :
- Place the comment on a separate line, not at the end of a line of code.
- Begin comment text with an uppercase letter.
- End comment text with a period.
- Insert one space between the comment delimiter (//) and the comment text.
- Do not create formatted blocks of asterisks around comments.
Example :
         // This is single line comment.
        
        /* This is
            Multiline

            Comment. */





Comments

  1. Nice blog for Unity Naming Convention.

    ReplyDelete
    Replies
    1. Thank you so much for your valuable feedback.

      Delete

Post a Comment

Popular posts from this blog

GDLC [Game Development Life Cycle]

Data Encryption - Decryption [Unity3d - C#]

DEVELOPER’S GUIDE TO UNITY3D MMO WITH NODE.JS USING SOCKET.IO

Unity Tiny | Tiny Mode | Instant Games | Playable Ads

DOTS - Unity3d

Unity's Back-end System

ANDROID GO - LIGHTER, SMARTER & OPTIMIZED ANDROID OS

Unity3d – Attributes