FSE Chap 5
FSE Chap 5
Chapter Five
Coding
School of Computing
Department of Software Engineering
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.
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.
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
29
Verification and validation
Code verification activities typically include:
32
Verification and validation
Code validation activities typically include:
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.
38