Software engineering principles

Case Study: Building Software in Python

Mark Pedigo

Principal Data Scientist

Roadmap

Roadmap showcasing what parts of the project we've finished and which we'll be starting.

Case Study: Building Software in Python

Modularity

Modularity: Key software engineering principle

  • Distinct, independent modules
  • Focused, specific functionality
  • Clear, well-defined interfaces
  • Separate development, testing, maintenance
Case Study: Building Software in Python

The DRY principle

"Don't Repeat Yourself": Key software engineering principle

  • Minimize repetition
  • Reusable components, classes
  • Write once, share widely
  • Clean, maintainable, less error-prone code
Case Study: Building Software in Python

Packaging

Packaging: Key software engineering principle

  • Organized folder hierarchy
  • Manage and structure code efficiently
  • The __init__.py file for module initialization
Case Study: Building Software in Python

Building a package

  • Minimal structure: package folder + Python file
  • Package: folder + __init__.py file
  • Short, lowercase directory names with underscores
  • __init__.py: Identifies folder as a package
Case Study: Building Software in Python

Absolute and relative imports

  • Suppose you have the following project structure
project \
   |--- package
   |    |--- module1.py
   |    |--- module2.py
   |--- main.py
  • Absolute Import: Full path from root
    • from package import module1
    • from package.module1 import function
  • Relative Import: Path based on current location (. = current, .. = parent)
    • from . import module1
    • from .module1 import function
  • Absolute: Clear, but less portable
  • Relative: Flexible, context-dependent
Case Study: Building Software in Python

Let's practice!

Case Study: Building Software in Python

Preparing Video For Download...