I'm working (slowly) on a small Flask project. One of my models is a class called Post
, which is a lightweight namedtuple
. Post
objects are created by a PostFactory
, because creating a Post
involves hitting a database. The PostFactory
holds the necessary database connection, so the Post
objects can be serialized.
What part of the model/view/controller division does a factory object naturally fit in? Is it part of the models, since it's tightly coupled with Post
objects? Or is it a controller, since it manipulates models?
Post
objects get passed a connection to the database and then pull the necessary info, but it seemed messy because posts have nothing to do with database connections. I thought that the thing that madePost
objects should be aPostFactory
, do you think that could be confusing because it's too limited? Is there a more reasonable name for "the class whose instances are used to createPost
objects"?Post
objects contain data that's been scraped from another site. They get passed an ID to look up, then pull down information about it from an API.