crc-cards

Why do we list collaborators in CRC cards?


In the CRC cards why do we list all the collaborators instead of just dependency. I mean if class A calls functions of B, why is A mentioned in the B class CRC collaborator section. It would be much better if we simply leave A in B's CRC card, as in A's CRC card B is already mentioned. This way we can figure out dependency also from CRC card, and if you know the function name of B class that A needs, we can mention that also in the A's CRC card. This would help even more by quickly generate the class and sequence diagrams. What specific functionality is achieved by mentioning B in A collaborators and A in B collaborators?


Solution

  • Because you don't want to be bogged down to the details of how the collaboration will happen. It may be that A calls out to B, but it may also be that A publishes an event on a message bus that B picks up, or it may be that B passes a callback object to A to which A passess its messages. Listing them as collaborators on both sides avoids having to work out actually how they will collaborate.