04
Jan
Object-Oriented Design with UML and Java sending a
Object-Oriented Design with UML and Java sending a message to some calendar object. The student object then has to perform some complex date arithmetic on its date of birth and today s date to determine its age. In the sequence diagram of figure 1.1 this processing is shown as an activation, the rectangle adjacent to the message arrow. Figure 1.1 also implies message propagation. When one object receives a message it often sends a cascade of other messages to other objects. The university object sends a message to the student object asking for its age. In turn, it sends a message to some calendar object requesting today s date. This example also demonstrates that an OO system is a mix of objects interacting to achieve the required objective. A university would typically have a large number of students. Unlike real students, all student objects exhibit the same behaviour and carry the same knowledge about themselves. We might model a student object with a name, date of birth and matriculation number. The actual state values for two student objects are presumably different since university matriculation numbers are unique. With a large university population we might, however, expect two or more students with the same name or two or more with the same date of birth. They are, however, all subject to the same behaviours. If one student can be asked for their age by sending some suitable message, then all students can be sent this message. How is this determined? All of our student objects support a single abstraction that we may choose to call Student. Other abstractions from this problem domain might include University, ProgrammeOfStudy and Tutor. We refer to the abstraction as the class of the object. A class is effectively a blueprint or template that fully describes the abstraction. The Student class describes any number of student objects. The Tutor class describes any number of tutor objects. The class describes the information an object holds to represent its state. The items of information are called attributes (sometimes also called properties). The class also defines the behaviours of such objects, listing the operations they can perform, i.e. the messages they can receive. The effect of these operations is described by its method. Figure 1.2 shows a simplified class diagram for a Student class. Student Attributes theName theDateOfBirth theMatriculationNumber Operations getName getAge Figure 1.2 UML class diagram (simplified) for a Student class In this figure we have a class Student with two operations and three attributes. Any student object we create from this template will have a state comprising three values for the attributes, i.e. theName, theDateOfBirth and theMatriculationNumber. Further, any
For high quality java hosting services please check tomcat web hosting website.
