Good Programming Practice - Students
Good Programming Practice - Students
Chris Rowlands
Software and Testing
Learning outcomes
• Gain an appreciation for how software is written at scale
• Understand basic errors, trapping and handling
• Know why we should use version control, and how to use it
• Understand the Software Development Lifecycle
• Know what unit-testing is, and how to do basic unit-testing
Software and Testing
Outline
• Errors and error handling
– Try / Except / Else
• Version Control
– Git
• Systems Development Life Cycle (SDLC)
• Unit testing
– Assert
Software and Testing
Error handling
• Warnings don’t mean anything bad has happened, but you might want to be
aware of something
• Syntax errors: the code doesn’t make sense
• Exceptions: Something went wrong
– Passed to the user by default
– Can be automatically handled
• Built-in exceptions: https://docs.python.org/3/library/exceptions.html
– TypeError: The code tried to pass a variable with the wrong data type to
a function or variable
– NameError: the code refers to a name, but that name can’t be found
– ZeroDivisionError: The code tried to divide by zero
• Can add your own
Software and Testing
Version Control
Approach Why are you wrong? Examples
No version What do you do if your code has a bug? Too many
control developers
Local backups Backups can be overwritten easily, and merging Windows
bugfixes from one version to another is hard Explorer
Local version How can other people easily make changes to RCS
control your code without breaking everything?
Centralized Not bad, but you usually need to pay for the CVS,
version control server, and you have a single point of failure Subversion
Distributed You aren’t; this is current standard practice for Git,
version control many software development projects Mercurial
Software and Testing
The V-Model
Software and Testing
Summary
• Discussed errors, try / except / else
• Introduced version control, the reasons for using it, and the basics of git
• Presented the SDLC, V-model, software requirements specification
• Discussed unit testing and how it helps prevent bugs / regressions
Software and Testing
Recommended reading
• SWEBOK V3 (IEEE)
• Test Driven Development By Example (Kent Beck)
• Clean Architecture: A Craftsman’s Guide to Software Structure and Design
(Robert C Martin)