Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Classes In UML. Object Concepts What is an object? How do objects communicate? How is an object’s interface defined? What have objects to do with.

Similar presentations


Presentation on theme: "Object Classes In UML. Object Concepts What is an object? How do objects communicate? How is an object’s interface defined? What have objects to do with."— Presentation transcript:

1 Object Classes In UML

2 Object Concepts What is an object? How do objects communicate? How is an object’s interface defined? What have objects to do with components?

3 Object Thing –Which of the following are objects: hammer, sphere, chemical process, fog, river, anger, cat, grayness, gray cat? State –Encapsulated in the data in its attributes Behaviour –Understands and reacts to certain messages - can receive messages and act on them. Identity –Can be a name, but shouldn’t be dependent on the values of its attributes.

4 Example myClock Understands the messages reportTime resetTimeTo(07:43), resetTimeTo(12:30) I.e. resetTimeTo (newTime) for any suitable value of newTime. –The object’s interface says it accepts messages of the form reportTime() and resetTimeto(newTime:Time) where Time is a type whose elements are the sensible values of time.

5 Messages A message contains a keyword called a selector - e.g. ResetTimeTo or ReportTime A message can have zero or more arguments, as specified by the definition of the message in the interface.

6 Interfaces The object’s public interface defines which messages it will accept regardless of where they come from. An object can send itself a message. The private interface is usable by itself and other privileged parts of the system - this specifies the attributes of the objects - not viewable to the public. E.g. a clock will have an attribute Time.

7 Classes A class of objects is a group of objects that have the same attribute types and behavior Rather than specifying each object, a class definition shows how the object is defined and behaves. A Clock class could contain an object myClock. The Clock class has an operation resetTimeTo(newTime:Time); i.e. all of the clocks can reset time. myClock is an instance of the Clock class.

8 Interfaces The object’s public interface defines which messages it will accept regardless of where they come from. –A public interface is a method that can be operated on the class. An object can send itself a message. The private interface is usable by itself and other privileged parts of the system - this specifies the attributes of the objects - not viewable to the public. E.g. a clock will have an attribute Time. –A private interface is an attribute that is held about the class.

9 What is a class? A business class is a group of objects that have similar attributes and operations. Objects are nouns. Only objects that need to have data about them recorded are suitable candidates. A user may be a business object, but probably is not.

10 Starting a class diagram Choose your candidate objects from the system description. For each candidate: –Is there more than one object in this class? –Is this object a system user / location? –Can you describe the type of information you need to know about each member of this group of objects?

11 What is an attribute? An attribute is the type of information you need to know about each object in a class. An attribute is an attribute when:- –it has a finite length –it has a single value for each object An attribute is not an attribute when:- –it in turn has several attributes –it has multiple values

12 What is an association? An association is a relationship between object classes. An association is used to implement a link between objects – to send messages or instructions from one class to another. –An object from one class can invoke a method on an object from another class, thereby accessing it through its public interface.

13 Operations What sort of operations are there in a class? –Constructor operations create new objects in the class. –Selector operations get information about and from an object in a class. –Mutator operations set information about and to an object in a class. –Destructor operations destroy objects of the class.

14 Starting class diagrams Rather than trying to define the entire class –concentrate on the data that is required for business classes –set up a data model, that can be converted into a relational database –later, loosen the structure, to give object- oriented advantages –add operations on the data.

15 Object oriented modelling and design Introduction The world as seen by the object object instances and classes object identifiers Super and sub classes Interaction between classes

16 three models Object model Static structure of objects in a system and their relationships Contains class diagrams functional model data value transformations within a system - Use case and object interaction diagrams dynamic model describes aspects that change over time: state transition diagrams function data time

17 Object modelling Object - Class (v instance) Attributes (v values) Abstraction and encapsulation –Abstraction is when a client of a module doesn’t need to know more than is in the interface. –Encapsulation is when a client of a module isn’t able to know more than is in the interface. Method - implementation of an operation for class Method signature - number and types of arguments; type of result value Notation of object instances and classes

18 Sample object classes

19 Adding relationships Links Physical or conceptual connection between object instances Associations Groups of links with common structure and common semantics bi-directional; forward and inverse direction implied by the name is forward

20 Link Notation class associations one to one zero or many one to many many to many * 1..* 1 1 1

21 Sample associations

22 Examples Identify some of the classes that you would expect to find in each of the following systems: –A system for a library –A system to manage hotel bookings –A mail-order clothes system –An airline booking system –A system for an X-ray clinic

23 Class Person List the attributes that a person would have in each of the following systems: –A system for a library –A payroll system –A voting registration system –A sporting club registration system –A dentist’s system


Download ppt "Object Classes In UML. Object Concepts What is an object? How do objects communicate? How is an object’s interface defined? What have objects to do with."

Similar presentations


Ads by Google