What is the difference between GRASP information expert and GRASP cohesion?

3.4k views Asked by At

Both concepts are very similar it is hard to tell which is which.

Please give an example of how you would differentiate them.

2

There are 2 answers

2
pvllnspk On BEST ANSWER

All GRASP concepts are linked, so you should consider them all together:

  1. "information expert" - question is "Which object should have needed behavior?" (Please see http://en.wikipedia.org/wiki/Domain-driven_design) like one of the answers for this question.
  2. "cohesion" - question is "How many different behaviors object have" http://en.wikipedia.org/wiki/GRASP_(object-oriented_design)

You should not learn these concepts without coding practice, write code/make refactoring - and you will get it.

0
Chinthaka Dharmasiri On

GRASP Design Patterns, as very rightly said here (Is Information Expert from GRASP and Modell from MVC the same?) are design principles and support you to evaluate your design decisions and implementation.

"Cohesion" in GRASP is an evaluative design pattern alongside "coupling". Thus you have to use them to analyse your design to figure out how cohesive and loosely coupled it is, which directly enhance re-usability and extensibility.

On the other hand, "Information Expert" can assist you in identifying which class should be given a particular responsibility. It tells you to assign a certain responsibility to the class which has the most information about it. |

Therefore in a simple shopping cart use case, you would give, A ShoppingItem to calculateItemPrice() based on quantity and unit price, and ShoppingCart to calculateTotalPrice().

This becomes a crucial factor, and note that most GOF design patterns actually are supporting this GRASP concept.

Most importantly. If you applied Information Expert pattern in your design, it should provide you with high cohesion in terms evaluating your design. Thats how Information Expert and Cohesion would go hand in hand, just like all other GRASP patterns.

Resources: http://www.cs.bgu.ac.il/~oosd051/uploads/stuff/ApplyingUMLandPatterns.pdf