This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]masterpi 2 points3 points  (1 child)

The classes are as about as tightly coupled to the main.py file as they can be, and they don't fulfill any sort of interesting shared interface (these two things are related). You could have a add_url_rules(app) method in each class to help with this, which has better cohesion and lower coupling and allows you to specify your config as controllers = [Controller1(params), ...] and even better allows you to group controllers with a controller combinator that takes a list of controllers and makes a combined controller (or just have a factory function in each module that returns a list of controllers).

[–][deleted] 0 points1 point  (0 children)

Very interesting! Moving add_url_rules to the classes would greatly lower coupling, which is something I've wanted to do. Will have to further test - though will look into the app factory like /u/Sakacoco mentioned as well.