4.1 Information Expert
The Information Expert pattern is a solution to the problem of determining which object should assume a particular responsibility.
During design, we make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.
Information Expert says: Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.
You need to consider how using Information Expert affects coupling and cohesion to determine if the pattern is a good choice.
InformationExpert_img1.gif 4.1.1 Example
Consider a simple part of a POS system as shown in the following class diagram:
graphic
The system must calculate a grand total of the items in the sale. How would you assign the responsibilities?
After applying Information Expert to this problem we end up with a solution shown in the following collaboration diagram:
graphic