With a friend of mine we are having an argument about the MVC (Model View Controller) Design Pattern. We are working on a project where two of our controllers are interdependent :
We are manipulating two types of objects : Pattern and Layout. A Layout is a composition of Patterns, which means that in the Model, a Layout has a std::vector of Patterns. Actually, when we want to create a Pattern, we must have created a Layout before because a Pattern cannot exists without being in a Layout.
Knowing that, we want to implement the Controllers for these two types of data and are arguing about who gets to store the Pattern datas.
From my friend point of view, as the Pattern cannot exists without a Layout we can let the Layout Controller the charge of storing the Pattern datas in the Layout Model.
From my point of view, as we are talking about Pattern data, I would prefer to let the Pattern Controller handle everything Pattern related. So the Pattern Controller would have a container of Patterns and the Layout Controller a list of pointers to the Patterns present in the Layout.
The advantage of my friend's technique is that we do not have the data in two places (Pattern Controller Container and Layout Data) and the advantage of mine is that the roles of each controllers are not mixed and that we can manipulate a Pattern without knowing what Layout it belongs to. What do you think ?
Aucun commentaire:
Enregistrer un commentaire