Organizing Code for Python Applications
Improve the maintainability and quality of your code. Attendees will become familiar with code modularity and organization principles.
Learning Objectives
- Translate code from a Python notebook into a local development repository.
- Identify areas in code that can be simplified for improved readability and maintainability.
- Refactor code by simplifying complex logic and removing duplication.
- Discuss code organization concepts such as the single responsibility principle, and the DRY principle.
- Organize code into modules to enhance scalability and maintainability, and practice importing code across multiple files.
- 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:
- Python Code Syntax and Style:
- Organizing Python Code, continued:
- “Notebook Translation” Exercise:
- Translate code from Python notebooks into a local development application.