CH8 Implementation
CH8 Implementation
CH8 Implementation
Implementation
Software implementation
2
Software implementation
3
Coding Principles
• Coding principles are closely related to the principles of
design and modeling.
• Developed software goes through testing, maintenance, and
reengineering. .
• Coding principles help programmers in writing an efficient
and effective code, which is easier to test, maintain, and
reengineer.
4
Coding Principles
• Information Hiding
– Data encapsulation binds data structures and their operations into a
single module.
– The operations declared in a module can access its data structures and
allow other modules to access them via interfaces.
– Other modules can access data structures through access specifiers and
interfaces available in modern programming languages.
– Information hiding is supported by data abstraction, which allows
creating multiple instances of abstract data type.
– Most of object-oriented programming languages such as C++, Java
etc., support the features of information hiding.
– Structured programming languages, such as C, Pascal, Fortran, etc.,
provide information hiding in a disciplined manner.
5
Coding Principles
• Information Hiding
Module
Data
6
Coding Principles
S1 T F
Condition F
Condition
S2
T
S1 S2
S2
…
Sn S3
8
Coding Principles
9
Coding Principles
10
Coding Styles
11
Coding Styles
13
Coding Standard
14
Coding Standard
• Error handling
• Modularization of code
• Program statement
• Adding comments
• Naming Conventions
• Don’t be too clever
• Code formatting
• Avoid deep nesting
• Limited use of global data
15
Coding Standard
• Miscellaneous standards
– Library functions should be used whenever required.
– Focus on clarity and then on efficiency.
– Repetitive expressions can be converted into functions.
– Parenthesize to avoid ambiguity.
– Complex and hard logical expressions can be transformed.
– Avoid use of goto statements.
16
Coding Process
17
Coding Process
Source file
Compilation and linking
No
Testing
No
Testing
OK
Yes
Executable program 19
Coding Process
• Test-Driven Development
– Developed software goes through a repeated maintenance process due
to lack of quality and inability to satisfy the customer needs.
– System functionality is decomposed into several small features.
– Test cases are designed before coding.
– Unit tests are written first for the feature specification and then the
small source code is written according to the specification.
– Source code is run against the test case.
– It is quite possible that the small code written may not meet the
requirements, thus it will fail the test.
– After failure, we need to modify the small code written before to meet
the requirements and run it again.
– If the code passes the test case implies the code is correct. The same
process is repeated for another set of requirements specification.
20
Coding Process
Test-Driven Development
Feature specifications
Bug fixing
Unsuccessful
Code change Run
Successful
Refactoring
Software
21
Coding Verification
22
Coding Verification
• Code review
– It is a traditional method for verification used in the
software life cycle. It mainly aims at discovering and fixing
mistakes in source codes.
– Code review is done after a successful compilation of
source codes. Experts review codes by using their expertise
in coding.
– The errors found during code verification are debugged.
• Following methods are used for code review:
– Code walkthrough
– Code inspection
– Pair programming
23
Coding Verification
• Code walkthrough
– A code walkthrough is a technical and peer review process of finding
mistakes in source codes.
– The walkthrough team consists of a reviewee and a team of reviewers.
– The reviewers examine the code either using a set of test cases or by
changing the source code.
– During the walkthrough meeting, the reviewers discuss their findings
to correct mistakes or improve the code.
– The reviewers may also suggest alternate methods for code
improvement.
– The walkthrough session is beneficial for code verification, especially
when the code is not properly documented.
– Sometimes, this technique becomes time consuming and tedious.
Therefore, the walkthrough session is kept short.
24
Coding Verification
• Code inspection
– It aims at detecting programming defects in the source code.
– The code inspection team consists of a programmer, a designer, and a
tester.
– The inspectors are provided the code and a document of checklists.
– In the inspection process, definite roles are assigned to the team
members, who inspect the code in a more rigorous manner. Also, the
checklists help them to catch errors in a smooth manner.
– Code inspection takes less time as compared to code walkthrough.
– Most of the software companies prefer software inspection process for
code review.
25
Coding Verification
• Pair programming
– It is an extreme programming practice in which two programmers
work together at one workstation, i.e., one monitor and one keyboard.
In the current practice, programmers can use two keyboards.
– During pair programming, code review is done by the programmers
who write the code. It is possible that they are unable to see their own
mistakes.
– With the help of pair programming, the pair works with better
concentration.
– They catch simple mistakes such as ambiguous variable and method
names easily. The pair shares knowledge and provides quick solution.
– Pair programming improves the quality of software and promotes
knowledge sharing between the team members.
26
Coding Verification
• Static analysis
– Source codes are not executed rather these are given as input to some
tool that provides program behavior.
– Static analysis is the process of automatically checking computer
programs.
– This is performed with program analysis tools.
– Static analysis tools help to identify redundancies in source codes.
– They identify idempotent operations, data declared but not used, dead
codes, missing data, connections that lead to unreachable code
segments, and redundant assignments.
– They also identify the errors in interfacing between programs. They
identify mismatch errors in parameters used by the team and assure
compliance to coding standards.
27
Coding Verification
• Testing
– Dynamic analysis works with test data by executing test cases.
– Testing is performed before the integration of programs for system
testing.
– Also, it is intended to ensure that the software ensures the satisfaction
of customer needs.
28
Code Documentation
29
Code Documentation
30
Summary
• Implementation is the coding phase in which software engineers translate
the design specifications into source codes in a programming language.
• Coding principles help programmers in writing an efficient and effective
code, which is easier to test, maintain, and reengineer.
• Coding standards play the role of maintaining commonality in coding
styles among programmers.
• Code verification is the process of identifying errors, failures, and faults in
source codes, which cause the system to fail in performing the specified
tasks.
• The traditional coding process and test-driven development (TDD) are two
widely used coding processes.
• Documentation help users in understanding the system operations.
Documents prepared during development are problem statement, software
requirement specification (SRS) document, design document,
documentation in the source codes, and test document.
31