Now that we are using blueprints in a modular manner, 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 return a Flask application object.
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.
Creating a factory function for our application object has several benefits. First, it allows the context...