Good Programming Practice
Programming Computer Science
AECSCOutline
What isa
Framework for
Software
Development?
 The framework for software development is a procedure that
can be followed when developing software solutions.
 It includes:
 Investigation (Problem description, Define requirements,
Development schedule)
 Design (Design data structures, Design and test algorithm)
 Develop (Develop and debug code, Unit testing and use of live
data)
 Evaluate (User acceptance testing, Developer retrospective)
Investigation
 Investigate
o Problem description – A breakdown of requirements
of the problem and parameters that need to be
considered.
o Define requirements – Examine the outcome
requirements and specifications the client may have.
o Development schedule – Create a timeline for when
each aspect of the task will be done. Gantt charts can
be useful for this.
Design
 Design
o Design data structures – The data structure design is a method
that starts with the specification of the program (what the
program does) and leads to the detailed program design
expressed in the form of pseudo-code.
o Design and test algorithm – Write the code in the chosen format
and with suitable software. Test it yourself, have others test it
and run it through testing code.
Develop
 Develop
 Develop and debug code – Expand on initial code
and debug it using range and type checking, testing
boundaries and parameters.
 Unit testing and use of live data – Break down the
code and test individual units of data, ensuring all
components are working as expected. Use live data
(real world, up-to-date data) to test your algorithms,
seeing how it will perform in the ‘real world’.
Evaluate
 Evaluate
 User acceptance testing – UAT is testing done
by the client to ensure it serves the purpose it
was designed for. The program should be almost
finalised.
 Developer retrospective – Meeting to discuss
how the development and implementation of the
software went and what could be improved next
time. Positive and constructive feedback is
necessary for the developer to grow and
implement changes in future updates.
Good
Programming
Practice
o validate input before processing - Input Validation, also known as data
validation, is the testing of any input (or data) provided by a user or
application against expected criteria. Input validation prevents
malicious or poorly qualified data from entering an information system.
o use of meaningful variable names - Meaningful variable names are
those that clearly articulate the data that the variable holds. It's as
simple as that. Avoid variable names that contain confusing or
ambiguous abbreviations, and certainly avoid meaningless variable
names such as v1 , v2 , etc.
o use constants for readability and maintenance - In programming, the
term constant refers to names representing values that don’t change
during a program’s execution. Constants are a fundamental concept in
programming, and Python developers use them in many cases.
However, Python doesn’t have a dedicated syntax for defining
constants. In practice, Python constants are just variables that never
change. To prevent programmers from reassigning a name that’s
supposed to hold a constant, the Python community has adopted a
naming convention: use uppercase letters.
Good
Programming
Practice
o use of comments to explain code - Commenting involves placing
Human Readable Descriptions inside of computer programs detailing
what the Code is doing. Proper use of commenting can make code
maintenance much easier, as well as helping make finding bugs faster.
Further, commenting is very important when writing functions that
other people will use.
o appropriate use of standard control structures - Control Structures can
be considered as the building blocks of computer programs. They are
commands that enable a program to “take decisions”, following one
path or another. A program is usually not limited to a linear sequence
of instructions since during its process it may bifurcate, repeat code
or bypass sections. Control Structures are the blocks that analyze
variables and choose directions in which to go based on given
parameters.
o use of appropriate indentation and white space - Indentation refers to
the spaces at the beginning of a code line. Where in other
programming languages the indentation in code is for readability only,
the indentation in Python is very important. Python uses
indentation to indicate a block of code.
Good
Programming
Practice
o one logical task per module - The single-responsibility
principle (SRP) is a computer programming principle that
states that "A module should be responsible to one, and only
one, actor." The term actor refers to a group (consisting of one
or more stakeholders or users) that requires a change in the
module.
o meaningful names for modules - A module’s interface should
be easy to use, easy to understand and easy to ensure
correctness. It should reflect this in its name and naming
patterns for consistency, readability and usability among
programmers.

7a Good Programming Practice.pptx

  • 1.
  • 2.
  • 3.
    What isa Framework for Software Development? The framework for software development is a procedure that can be followed when developing software solutions.  It includes:  Investigation (Problem description, Define requirements, Development schedule)  Design (Design data structures, Design and test algorithm)  Develop (Develop and debug code, Unit testing and use of live data)  Evaluate (User acceptance testing, Developer retrospective)
  • 4.
    Investigation  Investigate o Problemdescription – A breakdown of requirements of the problem and parameters that need to be considered. o Define requirements – Examine the outcome requirements and specifications the client may have. o Development schedule – Create a timeline for when each aspect of the task will be done. Gantt charts can be useful for this.
  • 5.
    Design  Design o Designdata structures – The data structure design is a method that starts with the specification of the program (what the program does) and leads to the detailed program design expressed in the form of pseudo-code. o Design and test algorithm – Write the code in the chosen format and with suitable software. Test it yourself, have others test it and run it through testing code.
  • 6.
    Develop  Develop  Developand debug code – Expand on initial code and debug it using range and type checking, testing boundaries and parameters.  Unit testing and use of live data – Break down the code and test individual units of data, ensuring all components are working as expected. Use live data (real world, up-to-date data) to test your algorithms, seeing how it will perform in the ‘real world’.
  • 7.
    Evaluate  Evaluate  Useracceptance testing – UAT is testing done by the client to ensure it serves the purpose it was designed for. The program should be almost finalised.  Developer retrospective – Meeting to discuss how the development and implementation of the software went and what could be improved next time. Positive and constructive feedback is necessary for the developer to grow and implement changes in future updates.
  • 8.
    Good Programming Practice o validate inputbefore processing - Input Validation, also known as data validation, is the testing of any input (or data) provided by a user or application against expected criteria. Input validation prevents malicious or poorly qualified data from entering an information system. o use of meaningful variable names - Meaningful variable names are those that clearly articulate the data that the variable holds. It's as simple as that. Avoid variable names that contain confusing or ambiguous abbreviations, and certainly avoid meaningless variable names such as v1 , v2 , etc. o use constants for readability and maintenance - In programming, the term constant refers to names representing values that don’t change during a program’s execution. Constants are a fundamental concept in programming, and Python developers use them in many cases. However, Python doesn’t have a dedicated syntax for defining constants. In practice, Python constants are just variables that never change. To prevent programmers from reassigning a name that’s supposed to hold a constant, the Python community has adopted a naming convention: use uppercase letters.
  • 9.
    Good Programming Practice o use ofcomments to explain code - Commenting involves placing Human Readable Descriptions inside of computer programs detailing what the Code is doing. Proper use of commenting can make code maintenance much easier, as well as helping make finding bugs faster. Further, commenting is very important when writing functions that other people will use. o appropriate use of standard control structures - Control Structures can be considered as the building blocks of computer programs. They are commands that enable a program to “take decisions”, following one path or another. A program is usually not limited to a linear sequence of instructions since during its process it may bifurcate, repeat code or bypass sections. Control Structures are the blocks that analyze variables and choose directions in which to go based on given parameters. o use of appropriate indentation and white space - Indentation refers to the spaces at the beginning of a code line. Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important. Python uses indentation to indicate a block of code.
  • 10.
    Good Programming Practice o one logicaltask per module - The single-responsibility principle (SRP) is a computer programming principle that states that "A module should be responsible to one, and only one, actor." The term actor refers to a group (consisting of one or more stakeholders or users) that requires a change in the module. o meaningful names for modules - A module’s interface should be easy to use, easy to understand and easy to ensure correctness. It should reflect this in its name and naming patterns for consistency, readability and usability among programmers.