0% found this document useful (0 votes)
18 views23 pages

FSE Chap 5

software engineering chapter 5 pdf

Uploaded by

eliasmesfin7825
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views23 pages

FSE Chap 5

software engineering chapter 5 pdf

Uploaded by

eliasmesfin7825
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Fundamental of Software Engineering

Chapter Five
Coding
School of Computing
Department of Software Engineering

December 28, 2024

1
Introduction
Coding is a fundamental aspect of software
engineering, serving as the means to
translate design concepts into executable
instructions for a computer system. It
involves writing and structuring lines of code
in a programming language to create
software applications and systems.
During the coding phase, developers utilize
their knowledge of programming languages,
algorithms, and data structures to implement
the software solution.
2
Coding Standards
Coding standards, also known as programming
conventions or coding guidelines, are a set of
rules and guidelines that define the style,
formatting, and best practices to be followed
while writing code.

These standards help promote consistency,


readability, maintainability, and collaboration
within software development teams

8
Coding Standards
Naming Conventions: Consistent and
meaningful names for variables, functions,
classes, and other code entities improve code
readability. Naming conventions may specify
capitalization rules, word separators, and naming
patterns.

Indentation and Formatting: Consistent


indentation and code formatting enhance code
readability. Guidelines may specify the use of
tabs or spaces, line length limits, and rules for
braces, parentheses, and operators.
9
Coding Standards
Comments and Documentation: Guidelines
often recommend the use of comments to explain
code intent, clarify complex logic, and provide
documentation for future reference.
Code Structure and Organization: Standards
may outline principles for organizing code files,
directories, and modules. They may suggest the
use of consistent file headers, imports, and code
sectioning.

Code Reusability and Modularity: Standards


may encourage the creation of reusable code
components, such as functions or classes, to
promote modularity and maintainability. 10
Standard

Coding convention
Teams strive to use the same coding
conventions in every regard:
Name your classes similarly, your variables,
your functions.
Comment the same way, format your code
the same way.
 By doing this, you ensure rapid understanding of
whatever module needs changing, and as they
evolve, your modules will not degenerate into a
HorseByCommittee appearance.

15
Benefits
Projects benefit from having strong
Coding Conventions/Standards because...
People can stop reformatting code and
renaming variables and methods whenever
working on code written by other people.
It's slightly easier to understand code that is
consistently formatted and uses a consistent
naming standard.
It's easier to integrate modules that use a
common consistent naming standard -- less
need to look up and cross-reference the
different names that refer to the same thing.
16
Good General Coding Principle
KISS
Keep it simple and small - always easier to read
and maintain (and debug!)
Be Explicit
SWYM - Say What You Mean
if ( WordCount ) vs. if ( WordCount != 0 )
n+3*x-5/y vs. n + ((3*x)-5)/y

23
Tips of Fixing Errors
Understand the problem before you fix it
Understand the program, not just the
problem
Confirm the error diagnosis
Relax
Save the original source code
Fix the problem, not the symptom
Make one change at a time
Check your fix
Look for similar errors
24
Coding Process
The coding process refers to the steps
involved in writing, testing, and refining
code to create software solutions. It is a
crucial part of the software development
lifecycle and involves translating
requirements and design specifications into
actual executable code

Understanding Requirements: The


coding process begins by understanding the
requirements and desired functionality of
the software. This includes analyzing user
needs, system specifications, and any design
or architecture documents. 25
Coding Process
Designing the Solution: Based on the
requirements, a high-level design is created
to outline the overall structure and
organization of the software. This includes
defining the modules, classes, functions, and
data structures that will be used.

Translating Design to Code: Developers


write the code, translating the design into
actual programming instructions. This
involves selecting an appropriate
programming language, utilizing coding
standards and best practices, and 26
Coding Process
Refactoring and Optimization: After
initial testing, the code may undergo
refactoring, which involves restructuring or
improving the code without changing its
functionality. This includes improving code
readability, removing duplicate code,
optimizing performance, and enhancing
maintainability.
Documentation: As code is written,
developers document the functionality,
purpose, and usage of the code. This helps
future developers understand the code and
promotes collaboration and maintainability. 27
Coding Process
Iterative Development: The coding
process often follows an iterative approach,
with multiple cycles of coding, testing, and
refinement. This allows for feedback and
continuous improvement, ensuring that the
software meets the desired requirements.

Deployment: Once the coding process is


complete, the software is prepared for
deployment, which includes packaging the
code, creating installers, and setting up the
necessary infrastructure to make the
software available to end users. 28
Verification and validation
code verification and validation specifically
focus on the correctness and quality of the
code itself.
Code verification is the process of
evaluating and checking the code to ensure
that it meets predefined standards,
guidelines, and specifications.
It focuses on determining whether the code
has been implemented correctly according
to the design, coding standards, and
requirements

29
Verification and validation
Code verification activities typically include:

Code Reviews: Manual examination of the


code by peers or experienced developers to
identify defects, coding errors, and
adherence to coding standards and best
practices.
Static Code Analysis: Automated analysis
of the code without executing it, using tools
that check for issues such as syntax errors,
code complexity, code duplication, coding
standards violations, potential bugs, and
30
Verification and validation
Unit Testing: Testing individual
components or modules in isolation to verify
their behavior and functionality. This
involves writing and running test cases to
exercise the code and ensure it produces the
expected outputs.

Code verification aims to catch coding


errors, bugs, and deviations from coding
standards early in the development process.
It helps ensure that the code is well-
structured, follows best practices, and
adheres to the intended design and 31
Verification and validation
Code Validation: Code validation, on the
other hand, focuses on evaluating the code
to determine if it fulfills the desired
functionality and requirements of the
software system. It involves testing the code
within the broader context of the system to
ensure that it behaves correctly and meets
the specified functional and non-functional
requirements

32
Verification and validation
Code validation activities typically include:

Integration Testing: Testing the


interaction between different components or
modules to verify that they work correctly
when combined. This includes testing the
integration points and ensuring that data
flows smoothly between the different parts
of the system.
System Testing: Conducting tests on the
entire software system to verify that it
functions as expected and meets the defined
requirements. This involves testing various
33
Verification and validation
User Acceptance Testing (UAT): Testing the
software with end-users or stakeholders to
ensure it meets their needs, performs as
expected, and delivers the desired
functionality.
Code validation ensures that the code, when
integrated into the larger software system,
functions correctly and meets the intended
purpose.

By performing code verification and


validation, developers can increase the
34
Metrics
In coding, metrics refer to quantitative
measurements and analysis of various
aspects of the codebase. These metrics
provide insights into the quality, complexity,
maintainability, and efficiency of the code.

Code Coverage: Code coverage measures


the percentage of code that is exercised by
tests. It indicates how much of the code is
being tested and can help identify areas that
need more testing.

35
Metrics
Cyclomatic Complexity: Cyclomatic
complexity is a quantitative measure of the
complexity of a program. It counts the
number of linearly independent paths
through the code, providing an indication of
how difficult the code is to understand and
maintain.

Code Duplication: Code duplication


metrics measure the amount of duplicated
code within a codebase. High levels of
duplication can lead to maintenance issues,
increased complexity, and difficulties in 36
Metrics
Performance Metrics: Performance
metrics measure the runtime performance of
the code, including factors such as execution
time, memory usage, and CPU utilization.
These metrics help identify performance
bottlenecks and areas for optimization.

Defect Density: Defect density measures


the number of defects or bugs found in the
code per unit of code size (e.g., per thousand
lines of code). It provides an indication of
the code's quality and can help identify
areas that require more attention and 37
Thank You!
Q?

38

You might also like