Model Reconciliation  «Prev  Next»
Lesson 3Test the interfaces
Objective Reconcile the sequence diagrams to the object model.

Test Interfaces

Verifying class interfaces

Name ( argument:datatype, ...): 
  returndatatype {constraints} 

Above is the standard operation signature format: Every event should translate into an operation. Once the operation signature has been defined, there are at least four tests to apply to your class diagrams:
  1. Verify that every operation on your sequence diagrams appears on the class diagram. Most computer-assisted software engineering (CASE) tools will automatically add interfaces to the class diagram when you add them to the sequence diagram. However, as you add and remove interfaces, the tools will not necessarily keep the two diagrams in sync. Operations deleted from your sequence diagrams may still appear on your classes. An operation moved from one class to another might still also be on the original class.
  2. Test for class cohesion. Verify that each interface supports the purpose of the object. Then look at all the interfaces for the class and determine whether all the interfaces support the same purpose. If the operations seem to work at two or more objectives, then you might want to split the class to improve cohesion.

View the slide show below to see an example of splitting a class.

Split Class to Improve Cohesion

1) Running Programs 1 2) Running Programs 2
  1. Examining the operations attributes reveals that the properties of the class fall into 2 distinct categories
  2. One option would be to split the Ticket class into two classes, including one that represents the use of a seat during a show.
Program 1 Program 2

Split Class to Improve Cohesion
  1. Test for consistency. If the same interface is referenced in more than one scenario, then verify that it is used the same way in each scenario. It is very easy to end up with identical names for operations that perform similar but distinct functions.
  2. Answer the following questions. Does the class have everything it needs to fulfill its defined purpose? Do the interfaces provide all the functionality that you would normally associate with the scope of responsibility that you assigned to the class? If not, then you will want to revisit the use cases and scenarios to find out what you might have overlooked. It is possible that the functionality was simply out of scope for this project. If so, leave it out. Otherwise, update the use cases, scenarios, and sequence diagrams to determine when the new interfaces are used and why.

Add New Interface to Model - Exercise

Click the Exercise link below to update the course project interfaces for a class.
Add New Interface to Model - Exercise