Lecture 10: Final Lecture & Exam Prep
Overview
This final lecture wraps up key topics and introduces advanced tools for robust software development. We consolidate learning objectives including strengthening programming skills, writing robust and secure code, effective collaboration using version control, and test-driven development practices.
Lecture Material (PDF)
Defensive Coding
Defensive coding anticipates and handles invalid inputs and errors before they cause problems. This proactive approach creates more robust and reliable software.
Exception Handling
Use try-except blocks to gracefully handle unforeseen runtime errors. Catch specific exceptions and provide meaningful error messages.
Static Code Analysis
Tools like SonarQube and PyLint help detect bugs and code smells early in development before they reach production.
Design by Contract
Define preconditions (what must be true before), postconditions (what must be true after), and invariants (what must always be true) to ensure code correctness.
Input Validation
Always validate inputs at system boundaries. Never trust external data without verification.
Modular Design & TDD
Combining modular design principles with test-driven development creates maintainable, well-tested software systems.
High Cohesion
Modules should be organised around a single, well-defined purpose. Each module does one thing well.
Low Coupling
Minimise dependencies between modules to simplify testing and maintenance. Changes in one module shouldn't cascade.
Test-Driven Development
Write tests before implementing functionality to ensure requirements are met. Follow the Red-Green-Refactor cycle.
Unit Tests
Isolate and test small parts of the codebase using frameworks like PyTest. Test individual functions and methods.
Integration Tests
Ensure that modules interact correctly using tools like Selenium. Test the system as a whole.
Code Coverage
Measure test coverage with tools like Coverage.py. Aim for high coverage of critical code paths.
User Testing Recap
Involve users early and often to identify usability issues before they become costly to fix.
Usability Testing
Evaluate user interactions to improve interface design. Observe how real users complete tasks.
Accessibility Testing
Ensure the software is usable by people with disabilities. Follow WCAG guidelines for inclusive design.
Early Involvement
Test with users throughout development, not just at the end. Iterative testing catches issues early.
API Design & Interaction
APIs enable communication between systems. Understanding how to design, test, and consume APIs is essential for modern development.
RESTful APIs
Design APIs following REST principles with clear endpoints, proper HTTP methods, and consistent response formats.
cURL Basics
Send HTTP requests and handle responses from APIs using the command line. Essential for debugging and testing.
Postman & Insomnia
Test and debug APIs using GUI tools. Create collections of requests and automate API testing.
CI/CD Pipeline
Continuous Integration and Continuous Deployment automate the build, test, and deployment process for faster, more reliable releases.
Continuous Integration
Merge code frequently and test changes automatically. Catch integration issues early before they compound.
Continuous Deployment
Deploy tested code to production automatically. Reduce manual steps and human error in releases.
Automated Testing
Run unit tests, integration tests, and linting on every commit. Maintain quality gates for merges.
Profiling & Performance
Identify bottlenecks and optimise code performance using profiling tools. Measure before optimising.
Command-line Tools
Use htop, perf, and ab to monitor and benchmark systems. Chrome DevTools also supports profiling for web applications.
Error Handling Strategies
Implement graceful degradation, retries, and fallback mechanisms. Systems should fail gracefully, not catastrophically.
Scalability Awareness
Consider the impact of module design on scalability. Design for growth from the start.
Real-World Best Practices
Professional development practices that improve code quality and team collaboration.
Code Reviews
Use GitHub or GitLab for peer reviews. When writing new code, explain it to the team. One person chairs, takes notes and actions. Others critique and ask questions.
Documentation
Document code clearly. Unit tests document functionality. Comments are your friend - use docstrings to explain purpose and usage.
Version Control Best Practices
Use Git effectively for individual and collaborative projects. Write clear commit messages and use meaningful branch names.
Exam Practice Materials
Prepare for your exam with practice questions covering all module topics. The lab includes multiple choice questions and open-ended scenarios.
Section A: Multiple Choice
40 marks total covering interaction design, code smells, Git commands, security, usability testing, profiling, and SOLID principles.
Section B: Open-Ended
Answer 2 of 3 questions worth 30 marks each. Topics include coupling/cohesion, defensive coding, user testing, TDD, and version control.
Mock Exam
Full mock exam with marking rubric to practice under exam conditions.
Tools & Further Reading
VLE Page
Course management and resources.