Both concepts are very similar it is hard to tell which is which.
Please give an example of how you would differentiate them.
Both concepts are very similar it is hard to tell which is which.
Please give an example of how you would differentiate them.
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
All GRASP concepts are linked, so you should consider them all together:
You should not learn these concepts without coding practice, write code/make refactoring - and you will get it.