Application factories

Now that we are using blueprints in a modular manner, however, there is another improvement we can make to our abstraction, which creates a factory for our application. The concept of a factory comes from the object-oriented programming (OOP) world, and it simply means a function or an object that creates another object. Our application factory will take one of our config objects, which we created at the beginning of the book and returned a Flask application object.

Note

The object factory design was popularized by the now famous book, Design Patterns: Elements of Reusable Object-Oriented Software, by the Gang of Four. To learn more about these design patterns and how they can help simplify a project's code, look at https://en.wikipedia.org/wiki/Structural_pattern ...

Get Mastering Flask now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.