Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CH8 Implementation

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

Chapter - 8

Implementation
Software implementation

• The software engineer translates the design specifications into


source codes in some programming language.
• The main goal of implementation is to produce quality source
codes that can reduce the cost of testing and maintenance.
• The purpose of coding is to create a set of instructions in a
programming language so that computers execute them to
perform certain operations.
• Implementation is the software development phase that affects
the testing and maintenance activities.
• A clear, readable, and understandable source code will make
testing, debugging, and maintenance tasks easier.

2
Software implementation

• Source codes are written for functional requirements but they


also cover some nonfunctional requirements.
• Unstructured and structured programming produce more
complex and tedious codes than object-oriented, fourth
generation languages, component based programming etc.
• A well- documented code helps programmers in understanding
the source codes for testing and maintenance.
• Software engineers are instructed to follow the coding process,
principles, standards, and guidelines for writing source codes.
• Finally, the code is tested to uncover errors and to ensure that
the product satisfies the needs of the customer.

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

Access to other modules


Function

6
Coding Principles

• Structure Programming Features


 Structured programming features linearize the program flow in
some sequential way that the programs follow during their
execution.
 The organization of program flow is achieved through the
following three basic constructs of structured programming.
– Sequence: It provides sequential ordering of statements,
i.e., S1, S2, S3, … Sn.
– Selection: It provides branching of statements using if-
then-else, switch-case, etc.
– Iteration: A statement can be executed repeatedly using
while-do, repeat-until, while, etc.
7
Coding Principles

• Structure Programming Features

S1 T F
Condition F
Condition
S2
T
S1 S2
S2

Sn S3

Sequence Selection Iteration

8
Coding Principles

• Maximize Cohesion and Minimize Coupling


– Writing modular programs with the help of functions, code,
block, classes, etc., may increase dependency among
modules in the software.
– The main reason is the use of shared and global data items.
– Shared data should be used as little as possible.
– Minimizing dependencies among programs will maximize
cohesion within modules; that is, there will be more use of
local data rather than global data items.
– High cohesion and low coupling make a program clear,
readable, and maintainable.

9
Coding Principles

• Code Reusability allows the use of existing code several


times.
•  KISS (Keep It Simple, Stupid)
– Most of the software are structurally complex but can be made simple
by using modularization and other designing principles.
• Simplicity, Extensibility, and Effortlessness
• Code Verification
• Code Documentation
• Separation of Concern
• Follow Coding Standards, Guidelines, and Styles

10
Coding Styles

• Each programming language has its own pattern of


programming. However, a programmer can make programs
efficient and effective in his own way.
• Every programmer, being a human being, thinks differently
from other programmers.
• Programmers can reduce the effort in the testing and
maintenance tasks.

11
Coding Styles

• Use of goto statement


• Use of control constructs
• Define user-defined data types
• Program size
• Information hiding
• Program documentation prologues
• Commenting code
• Use of temporary variable
• Avoid obscure side effects of subprograms
• Replace repetitive expressions by calls to a common function
• Avoid patching bad code
12
Coding Error

There are various categories of errors observed in programs.


• Some of the common types of errors are compilation errors
(i.e., syntax errors), logical errors, and run time errors.
• Compilation errors prevent programs from running.
• Logical errors are the most serious errors in a program. These
errors are related to the logic of program execution.
• Runtime errors are dynamic semantic and logical errors that
are not covered by the compiler. Such errors are reported at the
time of execution of the program.

13
Coding Standard

• Source codes are used by people other than author. The


programmer can produce quality source codes if he adheres to
the coding principles and coding styles.
• Coding standards provide general guidelines that can be
commonly adopted programmers and the development
organizations.

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

• The coding process describes the steps that programmers


follow for producing source codes.
• The coding process allows programmers to write bug-free
source codes.
• It involves mainly coding and testing phases to generate a
reliable code.

17
Coding Process

• The coding process describes the steps that programmers


follow for producing source codes.
• The coding process allows programmers to write bug-free
source codes.
• Two widely used coding processes.
– Traditional Coding Process
– Test-driven Development (TDD)
• The traditional programming process is an iterative and
incremental process which follows the “write-compile-debug”
process.
• TDD was introduced by Extreme Programming (XP) in agile
methodologies that follow the “coding with testing” process
18
Coding Process
Traditional Coding Process
Design specifications

Writing source codes

Source file
Compilation and linking

Object file Debugging

Is there any Yes


compilation
error?

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

Test case design

Write source code

Bug fixing
Unsuccessful
Code change Run

Successful
Refactoring

Software
21
Coding Verification

• Code verification is the process of identifying errors, failures,


and faults in source codes, which cause the system to fail in
performing specified tasks.
• Code verification ensures that functional specifications are
implemented correctly using a programming language.
• There are several techniques in software engineering which
are used for code verification.
– Code review
– Static analysis
– Testing

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

• Software development, operation, and maintenance processes


include various kinds of documents.
• Documents act as a communication medium between the
different team members of development.
• They 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.
• These documents are used by the development and maintenance
team members.

29
Code Documentation

• There are following categories of documentation done in the


system 
– Internal documentation
– System documentation
– User documentation
– Process documentation
– Daily 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

You might also like