Dispatching Object Model Concept

Dispatching in the object model is executing the correct code based on the type of a class. In this example, the age method is overloaded in the Student and Employee classes. Overloading occurs because the same name, age, is used for the methods in all three classes. There may be a reason for calculating the age of a Student or an Employee. For example, for insurance reasons, you may want the age of an Employee as of the first of the month instead of using today's date as might be defined in the Person class.

The object system dispatches, or executes, the correct code based on the type. If an object is of type Person, then that age method is executed. If an object is of type Student, then the age method defined for the Student class is executed. Likewise, if an object is of type Employee, then the age method defined for the Employee class is executed.

The object system ensures that the right method is executed on the right data. In other words, it is not possible to execute the wrong age method on the right data, or the right age method on the wrong data.

The ability to redefine methods on a class basis is known a polymorphism.

For this example, you should not see this type of case statement with an object system. It is handled by dispatching.

if type is Person then
    ... calculate age based on Person rules ....
else if type is Student then
    ... calculate age based on Student rules ....
else it type is Employee then
    ... calculate age based on Employee rules

Context for Dispatching Object Model Concept

The Savvy Manager's Guide

is also the author of a book that explains Web Services, service-oriented architecture, and Cloud Computing in an easy-to-understand, non-technical manner.

Web Services, Service-Oriented Architectures, and Cloud Computing: The Savvy Manager's Guide

by with David Dick

This is a guide for the savvy manager who wants to capitalize on the wave of change that is occurring with Web Services, service-oriented architecture, and—more recently—Cloud Computing. The changes wrought by these technologies will require both a basic grasp of the technologies and an effective way to deal with how these changes will affect the people who build and use the systems in our organizations. This book covers both issues. Managers at all levels of all organizations must be aware of both the changes that we are now seeing and ways to deal with issues created by those changes.