Behavioral Patterns  «Prev  Next»
Lesson 3 How do behavioral patterns help programmers?
ObjectiveTest the Vehicle classes.

Behavioral Patterns help Programmers by Solving Problems

Each behavioral pattern solves a different problem, but many share certain characteristics. Most behavioral patterns allow programmers or users to change the behavior of objects, classes or sub-systems by changing the parts that make up the system. This makes the system easier to understand by separating the essential parts from the variable parts. Furthermore, the interface generally remains the same even when the variable parts are swapped out.
Other beneficial effects of using behavioral patterns include:
  1. Decoupling objects from the objects that send requests to them and that they send requests to
  2. Allowing algorithms to be parameterized and selected dynamically
  3. Queuing messages and executing them in sequence (particularly useful in a multithreaded environment)

Behavior Diagrams

UML offers the following five behavior diagrams, which can be used to represent the dynamic behavioral aspects of an application.
  1. Use Case diagrams
  2. Sequence diagrams
  3. Activity diagrams
  4. Collaboration diagrams
  5. Statechart diagram
Behavioral Patterns mainly:
  1. Deal with the details of assigning responsibilities between different objects
  2. Describe the communication mechanism between objects
  3. Define the mechanism for choosing different algorithms by different objects at runtime

Testing Interface - Exercise

In this exercise, you will run some tests on the Vehicle classes you have already created.
Testing Interface - Exercise