Factory patterns in Python are explored as a way to create reusable, scalable, and maintainable code in data engineering contexts. The post covers the three types of design patterns (creational, structural, behavioral), explains how factory patterns work through separation of object creation from application logic, and provides practical code examples including file format parsers using decorators, database connection factories for MySQL and PostgreSQL, web scraping factories, and Dagster asset factories. The Dagster example shows how to refactor repetitive asset definitions into a single factory function driven by a configuration list, making it easy to add new API endpoints without modifying existing logic.

21m read timeFrom dagster.io
Post cover image
Table of contents
Example 2: Data orchestration
5 Impressions