Office Hour Topics
Error Handling
- Types of errors (TypeError vs. ValueError, custom exceptions)
- Raising errors vs. raising exceptions
- When to raise errors vs. using try-except blocks
- Best practice for try-except blocks within classes
Object-Oriented Programming (OOP)
- Truthiness and singleton values
- Equality in classes/objects
- isinstance() keyword and type guards
- Static and class variables
- Writing constructors for subclasses (what to pass to super().init)
- Getter and setter methods (when to use, best practices, validation in constructors)
- Helper classes (when and where to use them)
- What benefit is there to defining classes inside other class definitions?
- Overriding special methods (str, repr, etc.)
- Magic methods - which are most common/useful beyond init and repr
- Wrappers and decorators (what they are and when to use them)
- Polymorphism to refactor and DRY up repetitive code
- Abstract classes
- How to determine if it’s best to use classes or just functions
- How to determine which programming paradigm to use (OOP vs procedural vs alternatives)
- Why doesn’t Python have access modifiers (e.g. private, public, protected)?
- Why is OOP “out of fashion” and what alternatives are being used?
- SOLID principles
- Refactoring functions properly
Testing & Code Quality
- pytest fixtures and conftest files
- Parameterised tests
- Best practices for testing regular, class, and static methods
- Mocking and faking (advantages, disadvantages, when to use)
- Mocking datetime in tests
- How to read and interpret tests before coding (TDD and good practices)
- Test-driven development (is it standard in industry?)
- How to measure code quality beyond passing tests (readability, maintainability)
Python Modules & Language Features
- Lambda functions (how they work and why to use them)
- Filtering vs. list comprehensions
- With-blocks in Python
- The datetime module (common classes, functions, strptime/strftime)
- Difference between datetime and date
- Logging (vs. print, best practices)
- CSV module (meaning of delimiter and quotechar in csv.reader)
- Creating your own Python package/module for classes and functions
- Can you type-hint self? Why or why not?
- Docstrings vs. comments (when to use each and how much detail to include)
- Big O (how to work it out for operations, e.g. .join())
- Writing code under timed conditions (assessments, best practices)
Developer Tools & Workflow
- Concept of Git branches
- When to deactivate virtual environments
- Setting up terminal aliases and shortcuts (.zsh, oh-my-zsh, etc.)
- Useful VSCode shortcuts and the Play button (what it does and why to avoid it)