04
Jan
Chapter 1: Object Technology Student object can be
Chapter 1: Object Technology Student object can be sent messages to obtain their name or their age, i.e. getName and getAge. Figure 1.3 shows how in the UML we present a particular example of an object from some named class. This we refer to as an object instance or simply an object. The upper part of the figure names the class to which the object instance belongs, here Student. It also labels the object with some identifier by which we can refer to that object (s1). The lower part presents the attribute values maintained by the instance and represents its state. Here, for example, this particular Student instance has theName attribute with the value Ken Barclay as part of its state. Such a diagram element may be part of a much larger object diagram (or collaboration diagram) that we describe with the UML (see chapter 2). s1 : Student Attributes theName=Ken Barclay theDateOfBirth=27 September 2000 theMatriculationNumber=CompSci1234 Figure 1.3 An object instance As a further example, consider how we might model a bank account. An account can exhibit a variety of behaviours such as debiting or crediting some monetary amount, or requesting the account s current balance. These behaviours give rise to some of the likely account operations. Debit and credit transactions document the amount involved in the transaction, changing the balance for an account. The balance, along with the account number must be maintained by each bank account instance. Every example of a bank account carries its own data values for these attributes (see figure 1.4). acc : Account Attributes theNumber=NAP123 theBalance=150 Figure 1.4 A bank account instance To model an account as an object we describe its behaviours as operations and its state with attributes. During the execution of a system, an account object is requested to carry out its various operations, changing its attribute values as needed to reflect the effect of its actions. For example, in figure 1.4, a debit operation applied to such an account object results in a change to the value of theBalance attribute. Some operations are used to get information about an object, while others have some effect on an object s state. The operations that only give information about an object are referred to as enquiry operations. They enquire about some state information held by the object. The operation to obtain the value of an account s balance is of this type.
For high quality website hosting services please check cheap web hosting website.
