KEMBAR78
Coding standard and coding guideline | PPTX
SE ALA: Coding standards and
coding guidelines
Dhananjaysinh Jhala,
TY CE-1,
Batch B,
170410107027
INDEX
Introduction
Coding guidelines
Coding standards
Coding guidelines
 Control construct
 Some control constructs are selection statements
meaning that it selects which code to execute.
Other control constructs are loops, where
the control construct determines how many
times the loop will execute. C keywords related
to selection statements include: if , else , switch ,
case , break , default .
 Single entry and single exit constructs need to
be used. Standard control constructs must be
used instead of using wide variety of controls.
There are some commonly used programming
practices that help in avoiding the common errors.
 Use of Gotos
 Use of go to statements in our program makes it unstructured and it also imposes an overhead
on compilation process.
 Hence we should avoid them as much as possible or think of another alternative.
 Information hiding
 It should be supported as far as possible.
 In that case, only access functions and data structures must be made visible and the
information present in them must be hidden.
 Nesting
 Nesting means
defining one
structure inside
another. If nesting
is too deep then it
becomes top hard
to understand the
code. So we should
avoid deep nesting
of the code.
 User defined data types
 Modern programming languages allow the user to use user defined data types. It enhances the
readability of the code.
 Module size
 There is no standard rule about the size of the module but the large module size will not be
favourable always.
 Use of meaningful variable names for specific purpose
 We should avoid using same variable name in temporary loops for multiple purposes. Each variable must
be given some descriptive name so that the program becomes easy to understand.
 Well documentation
 Code must be well documented with the help of comment statements at appropriate places.
Coding standards
 Naming conventions
 Package and variable names must be in lower case
 Variable names mustn’t begin with numbers
 Constants must be in upper case
 Method name must be in lowercase
 Prefix is must be used for boolean type of variables. E.g. isEmpty, isFull…
Any good s/w development approach suggests to
adhere to some well defined standards or rules for
coding.
 Files
 Reader must get an idea about the purpose of the file by its name.
 Line length in file must be limited to 80 characters.
 Commenting/layout
 Comments are non executable part of code. But they also enhance readability of code.
 Comments must not only explain what is written, but also why a certain thing is written.
 Statements
 Declare some related variables on the same line and unrelated ones in another line.
 Class variable should never be declared public.
 Avoid use of break and continue in the loop.
 Avoid the use of do…while statement
 Limited use of globals
 These rules tell about which types of data that can be declared global and the data that can’t
be.
 Indentation
 Proper indentation is very important to increase the readability of the code. For making the
code readable, programmers should use White spaces properly.
 There must be a space after giving a comma between two function arguments.
 Each nested block should be properly indented and spaced.
 Error return values and exception handling conventions
 All functions that encountering an error condition should either return a 0 or 1 for simplifying
the debugging.
Coding standard and coding guideline

Coding standard and coding guideline

  • 1.
    SE ALA: Codingstandards and coding guidelines Dhananjaysinh Jhala, TY CE-1, Batch B, 170410107027
  • 2.
  • 3.
    Coding guidelines  Controlconstruct  Some control constructs are selection statements meaning that it selects which code to execute. Other control constructs are loops, where the control construct determines how many times the loop will execute. C keywords related to selection statements include: if , else , switch , case , break , default .  Single entry and single exit constructs need to be used. Standard control constructs must be used instead of using wide variety of controls. There are some commonly used programming practices that help in avoiding the common errors.
  • 4.
     Use ofGotos  Use of go to statements in our program makes it unstructured and it also imposes an overhead on compilation process.  Hence we should avoid them as much as possible or think of another alternative.  Information hiding  It should be supported as far as possible.  In that case, only access functions and data structures must be made visible and the information present in them must be hidden.
  • 5.
     Nesting  Nestingmeans defining one structure inside another. If nesting is too deep then it becomes top hard to understand the code. So we should avoid deep nesting of the code.
  • 6.
     User defineddata types  Modern programming languages allow the user to use user defined data types. It enhances the readability of the code.  Module size  There is no standard rule about the size of the module but the large module size will not be favourable always.
  • 7.
     Use ofmeaningful variable names for specific purpose  We should avoid using same variable name in temporary loops for multiple purposes. Each variable must be given some descriptive name so that the program becomes easy to understand.  Well documentation  Code must be well documented with the help of comment statements at appropriate places.
  • 8.
    Coding standards  Namingconventions  Package and variable names must be in lower case  Variable names mustn’t begin with numbers  Constants must be in upper case  Method name must be in lowercase  Prefix is must be used for boolean type of variables. E.g. isEmpty, isFull… Any good s/w development approach suggests to adhere to some well defined standards or rules for coding.
  • 9.
     Files  Readermust get an idea about the purpose of the file by its name.  Line length in file must be limited to 80 characters.  Commenting/layout  Comments are non executable part of code. But they also enhance readability of code.  Comments must not only explain what is written, but also why a certain thing is written.
  • 10.
     Statements  Declaresome related variables on the same line and unrelated ones in another line.  Class variable should never be declared public.  Avoid use of break and continue in the loop.  Avoid the use of do…while statement  Limited use of globals  These rules tell about which types of data that can be declared global and the data that can’t be.
  • 11.
     Indentation  Properindentation is very important to increase the readability of the code. For making the code readable, programmers should use White spaces properly.  There must be a space after giving a comma between two function arguments.  Each nested block should be properly indented and spaced.  Error return values and exception handling conventions  All functions that encountering an error condition should either return a 0 or 1 for simplifying the debugging.