3 ms·
one thing i always see glossed over is using application factories [0]. they are a bit harder to grok initially, since you have to hook your dependencies up via
by guitarbill 8y ago
one thing i always see glossed over is using application factories [0]. they are a bit harder to grok initially, since you have to hook your dependencies up via the factory, but they really help with testing/deploryment and scaling up flask apps. it's so much easier to do it at the start than to try and retro-fit it. similarly, blueprints from day 1 also make sense.
[0] http://flask.pocoo.org/docs/1.0/patterns/appfactories/ http://flask.pocoo.org/docs/1.0/patterns/appfactories/
- diminoten 8y agoI've been using Flask for a few years now, and the other day had to whip up a small app for a task at work. This is the first app I've used Blueprints and Application Factories, so I'm looking forward to better understanding their payoff in the future.
- cirgue 8y agoDo you know of a good side-by-side comparison of a simple app built with blueprints versus one without? I am still trying to wrap my head around the problem that they solve.
- guitarbill 8y agothing is, a simple app won't show you the benefits. blueprints are basically modules, and allow you to compose a big flask app from multiple blueprints. so as your app grows, you can add new features sanely (especially routing). a nice side-effect is having to think as features being correctly separated. initially, it's only a bit more effort, but as you scale it'll stop e.g. your views.py getting out of control, without resorting to hackery. again, it can be hard to do retro-actively, and once you realize you need it, the codebase is usually pretty bad. so i just do it from the start, as the extra effort is small then. (best practices prevent team members with less experience from committing attrocities and give them a good foundation to copy from)
- geezerjay 8y ago> one thing i always see glossed over is using application factories [0]. they are a bit harder to grok initially, IMHO what makes app factories hard to grok is the poor documentation and examples/tutorials on the topic. The official docs mention app factories are great but then don't include any clear example on how they could be used with routes. They do include examples that don't use app factories, thus that's what newbies use to get up and running, and afterwards keep on using because it works.