Coding: Coding Standards Coding Guidelines Code Walkthrough Code Inspection Software Documentation Gunning's Fog Index

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Coding

Introduction
Coding Standards
Coding Guidelines
Code Walkthrough
Code Inspection
Software Documentation
Gunning’s Fog Index

1
Introduction
The input to the coding phase is the design document.
During coding phase:
◦ Modules identified in the design document are
coded according to the module specifications.
At the end of the design phase we have:
◦ module structure (e.g. structure chart) of the system
◦ module specifications:
 data structures and algorithms for each module.
Objective of coding phase:
◦ transform design into code
◦ unit test the code.
2
Coding Standards
Good software development organizations
require their programmers to:
◦ adhere to some standard style of coding
called coding standards.
Many software development
organizations:
◦ formulate their own coding standards that
suits them most,
◦ require their engineers to follow these
standards rigorously
3
Coding Standards - Advantage
Advantage of adhering to a standard style of
coding:
◦ it gives a uniform appearance to the codes
written by different engineers,
◦ it enhances code understanding,
◦ encourages good programming practices.
A coding standard sets out standard ways of doing several things -
the way variables are named, code is laid out , comments etc.

4
Representative Coding Standards
Naming conventions for
◦ global variables,
◦ local variables, and
◦ constant identifiers.

Contents of headers of different modules


◦ name of the module,
◦ date on which the module was created,
◦ author's name,
◦ modification history,
◦ synopsis of the module,
◦ different functions supported, along with their input/output
parameters,
5
Coding Guidelines
Code should be easy to understand
◦ Don’t take pride in cryptic code
Code should be well documented
◦ Comments should be present
◦ Functions should be small
 Donot use Goto statements
Do not use the same variable for multiple
purpose

6
Code inspection and code walk
through
After a module has been coded,
◦ code inspection and code walk through are carried out
◦ ensures that coding standards are followed
◦ helps detect as many errors as possible before testing.

Detected errors require much less effort for


correction

Effort required is much higher if errors are


detected during integration or system testing

7
Code walk through
Informal code analysis technique
Some test cases are selected and their
execution are simulated by hand
Process of walk through are governed by
the developers experience and ability
Code walk through should not be one of
the evaluation criteria of a developer
Purpose should be error discovery and not
how to fix errors
8
Code Inspection
Its purpose is to find common made
errors by going through the code
Good companies record all the common
errors made by a developer which
becomes a checklist for future
Coding standard is also verified here
Examples
◦ Checking for infinite loops
◦ Checking for incorrect logical operators

9
Software Documentation
When developing a software product we
develop various kinds of documents apart
from the executable files and the source code:
◦ users' manual,
◦ software requirements specification (SRS)
document,
◦ design document, test document,
◦ installation manual, etc.
All these documents are a vital part of good
software development practice.
10
Software Documentation
Software documents can be classified into:
◦ internal documentation,
◦ external documentation (supporting documents).

Internal documentation – Documentation present in the


source code

External documentation – Documentation present other


than those in the source code

11
Internal Documentation
Good software development organizations
ensure good internal documentation through
coding standards and coding guidelines.
Example of unhelpful documentation:

◦ a = 10; /* a made 10 */
Observation suggests:

◦ meaningful variable names


is the most useful internal documentation.

12
External Documentation
A systematic software development style
ensures that all external documents are
produced in an orderly fashion.
An important feature of good documentation
is consistency.
All the documents should be up to date
◦ Out of date documents cause a lot of confusion

13
Textual Documents
Readability is an important attribute of
textual documents.
Readability determines understand ability
hence determines maintainability.
A well-known readability measure of text
documents:
◦ Gunning’s Fog Index.

14
Gunning’s Fog Index

Number of Words Percentage of


F=0.4 ` + words of 3 or
Number of Sentences more syllables

F corresponds to the number of years of


schooling to easily understand the document.
A document is easy to understand if:
• all sentences are small
• use only 4 to 5 words each
• small number of characters used per word
• normally not exceeding five or six characters.

15
Example of Gunning’s Fog Index
Rock-a-bye baby, on the treetop. When the wind blows,
the cradle will rock. When the bough breaks, the cradle
will fall. And down will come baby, cradle and all.

Number of words : 31
Number of sentences: 4
Number of 3 syllables or more word : 0

F = 0.4 *(31/4)+ (0/31*100)


= 0.4 * 7.75 = 3.1

i.e anyone with 3 years of schools can understand the above


16

You might also like