Organizing Code for Python Applications

Author

Michael Rossetti

Published

2024-10-18

Improve the maintainability and quality of your code. Attendees will become familiar with code modularity and organization principles.

Learning Objectives

  1. Translate code from a Python notebook into a local development repository.
  2. Identify areas in code that can be simplified for improved readability and maintainability.
  3. Refactor code by simplifying complex logic and removing duplication.
  4. Discuss code organization concepts such as the single responsibility principle, and the DRY principle.
  5. Organize code into modules to enhance scalability and maintainability, and practice importing code across multiple files.
  6. Use automated tools such as Code Climate to perform code maintainability assessments.

Prerequisites

Python Development Environment

This workshop requires the following software:

  • GitHub Desktop (requires a GitHub account)
  • VS Code Text Editor
  • Anaconda, Python, and Pip
  • Command Line Application (Terminal on Mac, Git Bash on Windows)

If you have never worked with these tools before, see the Local Development Environment Setup Guide. We will use a “Full Setup” for the exercises in this workshop.

Version Control

In this workshop we will strive to follow a version controlled development process, so you are recommended to familiarize yourself with the content from this Version Control Workshop beforehand.

Agenda

Workshop Content:

  • 0:00 - Welcome and Announcements:
    • Make sure you have already installed the prerequisite software and reviewed the prerequisite readings before the workshop.
  • 0:05 - Organizing Python Code:
  • 0:30 - “Codebase Cleanup” Exercise:
    • Practice refactoring and re-organizing Python code.
  • 0:60 - Stop

Extra Content: