1

I had a quick question about the Class Responsibility Collaboration cards for the Model View Controller architectural pattern:

enter image description here

Why doesn't the Model class's card include the View and the Controller classes as Collaborators?

Thanks!

Werner
  • 769
  • 2
  • 6
  • 19

1 Answers1

1

The point of the MVC pattern (well, one of the points) is that the Model doesn't know or care about Views. The Model's only responsibility is to expose data, and to boradcast notifications (without knowing who's listening to those broadcasts). Even non-Views could watch the model if they wanted.

In some variants of the MVC pattern, the Controller would be a collaborator of the Model, but in general the Model doesn't care about the Controller either.

Sneftel
  • 40,271
  • 12
  • 71
  • 104
  • So collaborators do not cover the "is used by" part of the relationship, only the "uses" part... So even if the model is used by the controller and the view, it does not use either of them, and so they are not considered collaborators. Very clear answer, thank you! Accepting this ASAP! – Werner Mar 26 '15 at 18:47
  • Exactly. A CRC card should only contain things that that single class needs to care about. If changing class B wouldn't require changing class A, then B shouldn't be on A's card. – Sneftel Mar 26 '15 at 18:49