SlideShare a Scribd company logo
1 of 27
1
Coding
At the end of the design phase we have:
module structure 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 some standard style
of coding
called coding standards.
3
Coding Standards
Many software development
organizations:
formulate their own coding
standards that suits them most,
require their engineers to follow
these standards.
4
Coding Standards
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.
5
Coding Standards
A coding standard
sets out standard ways of
doing several things:
the way variables are named,
code is laid out,
maximum number of source
lines allowed per function, etc.
6
Coding guidelines
Provide general suggestions
regarding coding style to be
followed.
7
Code inspection and
code walk throughs
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.
8
Code inspection and
code walk throughs
Detect as many errors as
possible during inspection and
walkthrough:
detected errors require less effort
for correction
much higher effort needed if errors
were to be detected during
integration or system testing.
9
Coding Standards and
Guidelines
Good organizations usually develop
their own coding standards and
guidelines:
depending on what best suits their
organization.
10
Representative Coding
Standards
Rules for limiting the use of globals:
what types of data can be declared
global and what can not.
Naming conventions for
global variables,
local variables, and
constant identifiers.
11
Representative Coding
Standards
Contents of headers for
different modules:
The headers of different
modules should be standard for
an organization.
The exact format for header
information is usually specified.
12
Representative Coding
Standards
Header data:
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,
global variables accessed/modified by the
module.
13
Naming conventions for global
variables, local variables, and
constant identifiers: A possible naming
convention can be that global variable
names always start with a capital letter,
local variable names are made of small
letters, and constant names are always
capital letters.
14
Representative Coding
Standards
Error return conventions and
exception handling mechanisms.
the way error and exception
conditions are handled should be
standard within an organization.
For example, when different functions
encounter error conditions
should either return a 0 or 1
consistently.
15
Representative Coding
Guidelines
Do not use too clever and difficult to
understand coding style.
Code should be easy to understand.
Many inexperienced engineers
actually take pride:
in writing cryptic and incomprehensible
code.
16
Representative Coding
Guidelines
Clever coding can obscure meaning
of the code:
hampers understanding.
makes later maintenance
difficult.
Avoid obscure side effects.
17
Representative Coding
Guidelines
Code should be well-documented.
Rules of thumb:
on the average there must be at least
one comment line
for every three source lines.
The length of any function should not
exceed 10 source lines.
18
Representative Coding
Guidelines
Lengthy functions:
usually very difficult to
understand
probably do too many different
things.
19
Representative Coding
Guidelines
Do not use goto statements.
Use of goto statements:
make a program unstructured
make it very difficult to
understand.
20
Code review
Code review for a model is carried out after the
module is successfully compiled and the all the
syntax errors have been eliminated.
Normally, two types of reviews are carried out
on the code of a module.
These two types code review techniques are
code inspection and code walk through.
21
Code Walk Through
An informal code analysis technique.
undertaken after the coding of a module is
complete.
A few members of the development team
select some test cases:
simulate execution of the code by hand using
these test cases.
Discussion should focus on discovery of
errors:
and not on how to fix the discovered errors.
22
The main objectives of the walk through are to
discover the algorithmic and logical errors in the
code.
The members note down their findings to
discuss these in a walk through meeting where
the coder of the module is present.
The team performing code walk through should
not be either too big or too small.
Ideally, it should consist of between three to seven
members.
23
Code Inspection
 In contrast to code walk through, the aim of code
inspection is to discover some common types of errors
caused due to oversight and improper programming.
 In addition to the commonly made errors, adherence to
coding standards is also checked during code inspection.
 Good software development companies collect statistics
regarding different types of errors commonly committed
by their engineers and identify the type of errors most
frequently committed.
 Such a list of commonly committed errors can be used
during code inspection to look out for possible errors.
24
Commonly made errors
Use of uninitialized variables.
Nonterminating loops.
Array indices out of bounds.
Improper storage allocation and
deallocation.
Actual and formal parameter mismatch in
procedure calls.
Jumps into loops.
25
Code Inspection
Use of incorrect logical operators
or incorrect precedence among operators.
Improper modification of loop variables.
Comparison of equality of floating point
values, etc.
Also during code inspection,
adherence to coding standards is checked.
26
Programming (Coding) Style &
Conventions
Check for errors early and often.
Return from errors immediately.
Have you checked for compiler warnings?
Warnings often point to real bugs.
If possible reduce object and file dependencies.
Eliminate needless import or include statements.
Check again for warnings or errors before
committing source code.
27

More Related Content

Similar to Coding Standards & Guidelines

code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdf
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdfcode_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdf
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdfsarah david
 
Standard embedded c
Standard embedded cStandard embedded c
Standard embedded cTam Thanh
 
Coding and testing in Software Engineering
Coding and testing in Software EngineeringCoding and testing in Software Engineering
Coding and testing in Software EngineeringAbhay Vijay
 
Software Coding- Software Coding
Software Coding- Software CodingSoftware Coding- Software Coding
Software Coding- Software CodingNikhil Pandit
 
How Virtual Compilation Transforms Static Code Analysis
How Virtual Compilation Transforms Static Code AnalysisHow Virtual Compilation Transforms Static Code Analysis
How Virtual Compilation Transforms Static Code AnalysisCheckmarx
 
Code-Review-Principles-Process-and-Tools (1)
Code-Review-Principles-Process-and-Tools (1)Code-Review-Principles-Process-and-Tools (1)
Code-Review-Principles-Process-and-Tools (1)Aditya Bhuyan
 
Software coding & testing, software engineering
Software coding & testing, software engineeringSoftware coding & testing, software engineering
Software coding & testing, software engineeringRupesh Vaishnav
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsSafety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsAndrey Karpov
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationBlue Elephant Consulting
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review ProcessDr. Syed Hassan Amin
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelinesLalit Kale
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...DevDay.org
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleikram_ahamed
 
Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)lqi
 

Similar to Coding Standards & Guidelines (20)

9-Coding.ppt
9-Coding.ppt9-Coding.ppt
9-Coding.ppt
 
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdf
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdfcode_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdf
code_review_checklist_6_actions_to_improve_the_quality_of_your_reviews.pdf
 
Standard embedded c
Standard embedded cStandard embedded c
Standard embedded c
 
Coding
CodingCoding
Coding
 
Software coding and testing
Software coding and testingSoftware coding and testing
Software coding and testing
 
Coding and testing in Software Engineering
Coding and testing in Software EngineeringCoding and testing in Software Engineering
Coding and testing in Software Engineering
 
Software Coding- Software Coding
Software Coding- Software CodingSoftware Coding- Software Coding
Software Coding- Software Coding
 
How Virtual Compilation Transforms Static Code Analysis
How Virtual Compilation Transforms Static Code AnalysisHow Virtual Compilation Transforms Static Code Analysis
How Virtual Compilation Transforms Static Code Analysis
 
Code-Review-Principles-Process-and-Tools (1)
Code-Review-Principles-Process-and-Tools (1)Code-Review-Principles-Process-and-Tools (1)
Code-Review-Principles-Process-and-Tools (1)
 
Software coding & testing, software engineering
Software coding & testing, software engineeringSoftware coding & testing, software engineering
Software coding & testing, software engineering
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsSafety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
Code Inspection
Code InspectionCode Inspection
Code Inspection
 
Code Review
Code ReviewCode Review
Code Review
 
Code Review
Code ReviewCode Review
Code Review
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
 
Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

Coding Standards & Guidelines

  • 1. 1 Coding At the end of the design phase we have: module structure 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. 2 Coding Standards Good software development organizations require their programmers to: adhere some standard style of coding called coding standards.
  • 3. 3 Coding Standards Many software development organizations: formulate their own coding standards that suits them most, require their engineers to follow these standards.
  • 4. 4 Coding Standards 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.
  • 5. 5 Coding Standards A coding standard sets out standard ways of doing several things: the way variables are named, code is laid out, maximum number of source lines allowed per function, etc.
  • 6. 6 Coding guidelines Provide general suggestions regarding coding style to be followed.
  • 7. 7 Code inspection and code walk throughs 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.
  • 8. 8 Code inspection and code walk throughs Detect as many errors as possible during inspection and walkthrough: detected errors require less effort for correction much higher effort needed if errors were to be detected during integration or system testing.
  • 9. 9 Coding Standards and Guidelines Good organizations usually develop their own coding standards and guidelines: depending on what best suits their organization.
  • 10. 10 Representative Coding Standards Rules for limiting the use of globals: what types of data can be declared global and what can not. Naming conventions for global variables, local variables, and constant identifiers.
  • 11. 11 Representative Coding Standards Contents of headers for different modules: The headers of different modules should be standard for an organization. The exact format for header information is usually specified.
  • 12. 12 Representative Coding Standards Header data: 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, global variables accessed/modified by the module.
  • 13. 13 Naming conventions for global variables, local variables, and constant identifiers: A possible naming convention can be that global variable names always start with a capital letter, local variable names are made of small letters, and constant names are always capital letters.
  • 14. 14 Representative Coding Standards Error return conventions and exception handling mechanisms. the way error and exception conditions are handled should be standard within an organization. For example, when different functions encounter error conditions should either return a 0 or 1 consistently.
  • 15. 15 Representative Coding Guidelines Do not use too clever and difficult to understand coding style. Code should be easy to understand. Many inexperienced engineers actually take pride: in writing cryptic and incomprehensible code.
  • 16. 16 Representative Coding Guidelines Clever coding can obscure meaning of the code: hampers understanding. makes later maintenance difficult. Avoid obscure side effects.
  • 17. 17 Representative Coding Guidelines Code should be well-documented. Rules of thumb: on the average there must be at least one comment line for every three source lines. The length of any function should not exceed 10 source lines.
  • 18. 18 Representative Coding Guidelines Lengthy functions: usually very difficult to understand probably do too many different things.
  • 19. 19 Representative Coding Guidelines Do not use goto statements. Use of goto statements: make a program unstructured make it very difficult to understand.
  • 20. 20 Code review Code review for a model is carried out after the module is successfully compiled and the all the syntax errors have been eliminated. Normally, two types of reviews are carried out on the code of a module. These two types code review techniques are code inspection and code walk through.
  • 21. 21 Code Walk Through An informal code analysis technique. undertaken after the coding of a module is complete. A few members of the development team select some test cases: simulate execution of the code by hand using these test cases. Discussion should focus on discovery of errors: and not on how to fix the discovered errors.
  • 22. 22 The main objectives of the walk through are to discover the algorithmic and logical errors in the code. The members note down their findings to discuss these in a walk through meeting where the coder of the module is present. The team performing code walk through should not be either too big or too small. Ideally, it should consist of between three to seven members.
  • 23. 23 Code Inspection  In contrast to code walk through, the aim of code inspection is to discover some common types of errors caused due to oversight and improper programming.  In addition to the commonly made errors, adherence to coding standards is also checked during code inspection.  Good software development companies collect statistics regarding different types of errors commonly committed by their engineers and identify the type of errors most frequently committed.  Such a list of commonly committed errors can be used during code inspection to look out for possible errors.
  • 24. 24 Commonly made errors Use of uninitialized variables. Nonterminating loops. Array indices out of bounds. Improper storage allocation and deallocation. Actual and formal parameter mismatch in procedure calls. Jumps into loops.
  • 25. 25 Code Inspection Use of incorrect logical operators or incorrect precedence among operators. Improper modification of loop variables. Comparison of equality of floating point values, etc. Also during code inspection, adherence to coding standards is checked.
  • 26. 26 Programming (Coding) Style & Conventions Check for errors early and often. Return from errors immediately. Have you checked for compiler warnings? Warnings often point to real bugs. If possible reduce object and file dependencies. Eliminate needless import or include statements. Check again for warnings or errors before committing source code.
  • 27. 27