Writing Clean Code in Python


CodePython - Version:1
Description
In this intensive hands-on workshop we’ll learn how to write clean, readable, and maintainable Python code that scales. We’ll learn to apply core software-engineering principles, organize projects professionally, and implement essential design patterns and best practices used in real-world development. Through short exercises and refactoring labs, we’ll practice turning messy scripts into elegant, testable, and well-structured programs that any teammate would be proud to read.
Intended audience
Python Developers
Expand All
  • Introduction and Philosophy of Clean Code
    • - Why clean code matters?
    • - .Key principles: DRY, KISS, YAGNI, SOLID
    • - Pythonic mindset.
  • Python Best Practices and Style
    • - PEP-8 essentials (naming, spacing, imports, line length)
    • - Type hints.
    • - Comments and docstrings.
    • - Modules and Packages.
    • - Virtual environment.
    • - Lab – using venv and pip.
  • Functions and Classes the Clean Way
    • - Function signatures and side-effects
    • - Encapsulation & cohesion in classes
    • - Composition vs inheritance
    • - Lab – refactoring code
  • Design Patterns in Python
    • - What are design patterns?
    • - Creational, structural and behavioral patterns.
    • - When to use patterns and when not to use them.
    • - Lab – Design patterns.
  • Organizing Python Projects
    • - Directory structure and imports.
    • - Configs and environment variables.
    • - Separation of concerns.
    • - Using tools like black, ruff, pytest.
    • - Lab – building project
  • Refactoring and Code Smells
    • -Identifying long functions, deep nesting, duplication
    • -Refactoring techniques (extract method/class, simplify conditionals)
    • -Lab – refactoring
  • Testing
    • - Unit test
    • - TDD
    • - Using PyTest
    • - Lab – building tests.