Beruflich Dokumente
Kultur Dokumente
Object Model
Based on a perception that a real world consists of a set of basic objects, called Objects and Relationships among these objects.
Structure Diagram
Object
Object is anything that has space and shows behaviour ObjectObject- Thing which has existence distinguishable from other objects (things) independent existence concrete or abstract described by its space and behaviour has its own identity
Exercise
Abstraction
Look at only that snapshot of the world that is of interest Employee Rama: Name, salary Hire, Retire Project Robot: start date, end date Calc. expenditure, find status not name of grandfather
Abstraction: identify the common properties across things Rama and Raghu are employees Robot and Moon mission are projects common Name, salary start, end date are common
Structuring Abstraction
Most basic structuring mechanism is Classification Class C = {x|x satisfies P} where P is a predicate Normally, P is a statement in the propositional logic
Example Employee = (person|person satisfies is employee} Male Employee = {person|person is male and is employee}
Object Class
An object class is a class of objects of the same type; objects that share the same properties. Object class : Employee, Project, Department Sets are not necessarily disjoint Sets : Male Employee and Married Employee Can be a subset Sets : Person and Feminine Person
Employee
A Relationship
Example Rama owns Ekta Bhawan Raghu owns Ashiana Dravid plays cricket Pillai plays hockey TV model 3344 is available in the Sony showroom at Solan
relationship
An association class is a class of relationships of the same type, having common properties
Let E1, E2, ... En be entity sets and E1, E2, ... En participate in association A A E1 x E2 x ... x En = {<e1, e2, ..., en> ei Ei } <e1, e2, ..., en> is an association, A is the association set Example The degree of the association: n Owns(Person, House) owns Plays(Person, game) House Person Available(TV, Shop, City)
Roles
Role is the function performed by the object in the association. Example Owns(Person, House) Plays(Person, game) Available(TV, Shop, City)
owns Person owner owned House
Exercise
Define associations for the following situations Students register for courses Students register for courses taught by different teachers A timetable is made for a course taught by a teacher in a classroom during a given period
Cardinality/Multiplicity
Expresses the 1:1, 1:N, M:N constraint on the relation defining the association Answers the question How many Example Owns(Person, House) Plays(Person, game) Available(TV, Shop, City)
1 Person owner owned owns
Attributes
Descriptive Property
Takes values from a permitted set - Domain or value set Information about an object or association can be expressed by a set of (attribute, value) pairs
Person with attributes name, age { (name, Hari); (age, 20) } Works_for : attributes name, project, percent_of_time { (name, Raghu); (project, Insurance); (Percent_of_time, 30) }
Attributes
An attribute is a function from one object set or association set into a value set or a cartesian product of value set simple attribute Ai : O or A -----> Vi name : Person ---> string composite attribute Ai : O or A -----> Vi1 X Vi2 X..Vin streetno street streetname
address
city pincode
Attributes
Single vs Multivalued
Multivalued - a set of values for an object/association (tel-number, 239201 and 245361) Base vs. Derived attribute
Base - value directly available Derived - value derived through other attributes/computation Base: Individual marks, Derived: Overall grade Base: date-of-birth, Derived: age date-of-
Owns share
1 Person owner
3 House owned
Exercise
Define attributes for the following relationships Students register for courses A timetable is made for a course taught by a teacher in a classroom during a given period Nehru was the Prime Minister, Minister of Science, and Congress President
Operations
An operation is an abstraction of what objects can do, services they provide.
Organizing/Descriptions
Employee name doB telNo <<Constr>> employee() stereotype <<actions>> hire() promote() retire() <<actions>> hire() promote() retire() Responsibilities -- handle HR activity stereotype Employee name doB telNo <<Constr>> employee()
Exercise
Model the following situations and represent them as structure diagrams Students register for courses A timetable is made for a course taught by a teacher in a classroom during a given period Nehru was the Prime Minister, Minister of Science, and Congress President
Exercise
A wholesale vegetable market sells different kinds of fruit and vegetables at different prices. Fruit is sold in units of a box whereas vegetables are sold in units of 5kg. Corporate/regular customers are offered a 10% discount on the price whereas others can negotiate the price up to a discount of 5%. A corporate/regular customer is one who buys at least Rs.1000/- worth in at least two lots per month. Fruit, Vegetable, list price, unit, discount, irregular customer, corporate customer, negotiated discount sale price? : can calculate or can store unit of produce? Sale? of a product at a price to a customer in some quantity Corporate customer definition as a constraint on customer
Solution
Fruit Name Rate Buys Discount Buyer Name Type Purchase_ history Classify() Veg Name Rate Buys Discount
Modeling Exercise
A timetable is made for a course taught by a teacher in a classroom during a given time period. There are different kinds of courses, subject elective, open elective, core, audit. For elective courses, the time period of the course is decided by the teacher of the course. Draw a structure diagram for building time tables How to represent associations that have a degree greater than 2 How to represent different kinds of courses
Abstraction Revisited
Classification represents an is member-of relationship between the class and its members
Abstraction Hierarchies
When there are too many details, we may want to view these properties in a hierarchy of abstractions most general at the root most specific at the leaves
Abstraction provides a structuring discipline Identify universally applicable interesting properties Determine those special properties applicable to different subsets Apply recursively to each subset till properties are exhausted
Break a main class into subordinate classes and arrange them hierarchically
Aggregation
Produces objects that are in a hierarchical relationship with one another Transforms a relationship between several named objects into a higherlevel named object Relationship Reserves associate Objects person, room, duration building, street, city Aggregate reservation address
An aggregation represents is part of relationship between objects Person is part of reservation Duration is part of reservation Building is part of address
Aggregation
Want to express relationship with a relationship
Booking Person Book Flight
Ticket Ticket
Aggregation
Provides meaning to a relationship Student P received grade G in a class of the course C# with CH credit hours and description D taught by instructor I during semester S in room R
G P
C#
CH
Rel
Aggregation
Performance
Class
Course
C#
CH
Object classes: Building, Street, City Aggregate class: Address Address = Building X Street X City 1 Address has 1 Building part 1.. * member 1 City 1.. *
1 street
Exercise
A passenger train is put together in a railway yard. It must have an engine and a number of bogies of different classes: Chair car, First class, and Second class. Each bogey has a determined number of people to seat and sleep. It has a number that identifies it. Every bogie has a conductor. Each train class has its own ticket checker. A given engine can be attached or detached from a train. Similarly, bogies can be attached or detached to a train. Draw a structure diagram. Write an O-O program to implement this structure.
Engine
First
Second
Number
Ticket checkes
Exercise
At the time of admission a student is allowed to register for a degree programme. Each degree is identified by a title and has a determined number of credits for its award. Associated with each programme is a Head of Department who has a name, an employee number, and a rank. Once a student is registered, he/she is given a place in the hostel. Information about the hostel number and hostel room number is to be maintained. Draw a structure diagram. Define operations for each class and develop an OO program
Generalisation/Specialisation
An abstraction that allows a class to be treated as a high level single named object class, called generic object class Generalisation: Relationship between a more general class and a specific kind of that class.
Generic Hierarchies
Document Root generic object
Periodical
Fixed
Journal
Magazine
Book
Manual
An individual which is a book is a member of each of the classes, Book, Fixed, and Document
Generic Hierarchies
A generic hierarchy can have a generic object which is an immediate descendent of one or more generic objects
Output Unit
Winchester
CD
Inheritance
Inheritance : Properties of the generic object are inherited downwards
Balance Account
Belongs Customer
Savings
Current
Generic Hierarchies
A higher level generic object is referred to as a super class Its direct lower level object is called its sub class Properties Sub setting: The set of members of a subclass is a subset of the set of members of super-class Inheritance: The set of properties of a subclass is a superset of the set of properties of its superclass
Exercise
A passenger train is put together in a railway yard. It must have an engine and a number of bogies of different classes: Chair car, First class, and Second class. Each bogey has a number that identifies it. A first class bogey can sleep 48 persons and can seat 1.5 times as many; a second class bogey can sleep and seat 75 persons whereas a chair car can seat 53 persons. Identify and draw a generalisation hierarchy.
Constraints on Hierarchies
Participation: between generic objects across hierarchy levels Mandatory: all members of super-class are mapped to one or other subclass {Super} = {Sub1} U {Sub2}U ..{Subn} Optional: some members of super class are unmapped {Super} {Sub1} U {Sub2}U ..{Subn}
Disjointness: between generic objects at a given level Partitioned: Two subclasses are mutually disjoint {Sub1} + {Sub2} = null Overlapping: Two subclasses are not mutually disjoint
Exercise
What are the participation and disjointness constraints in the hierarchy
Doctor
Physician
Surgeon
Cardiologist
Orthopaedist
Neuro
Opthalmic
Others
Constraints on Hierarchies
Strictness: what is inherited Strong inheritance: all the properties of the super class are inherited by the sub class Weak/Loose inheritance: only a subset of the properties are inherited
Exercise
A passenger train is put together in a railway yard. It must have an engine and a number of bogies of different classes: Chair car, First class, and Second class. Each bogey has a number that identifies it. A first class bogey can sleep 48 persons and can seat 1.5 times as many; a second class bogey can sleep and seat 75 persons whereas a chair car can seat 53 persons. In the hierarchy for this problem drawn earlier, identify all constraints.
Attributes may carry special information of no relevance to class being generalised Generic object Employee Attributes Max-salary, Avg-salary MaxAvg-
borrow
Faculty Document
borrows
Periodical
Fixed
Journal
Magazine
Book
Manual
Dependency
Usually initial class diagrams will not have any significant number of dependencies in the beginning of analysis but will as more details are identified.
Dependency
AbstractClass {abstract} attribut e concreteOperation() abstractOperation() generalization ClassName
Among Classes
<<interface>> InterfaceName operation() <<instanceOf>> realization
<<metaclass>> MetaClassName
-simpleAttribute: Type = Default #classAttribute: Type +/derivedAttribute: Type +operation(in arg: Type = Default): ReturnType <<instanceOf>> objectName: ClassName Attribute = value simpleAttribute: Type = Default classAttribute: Type /derivedAttribute: Type
<<use>>
ClientClass
bind:
parameters
the source instantiates the target template using the given actual
derive: the source may be computed from the target friend: the source is given special visibility into the target instanceOf : the source object is an instance of the target classifier instantiate: the source creates instances of the target powertype: powertype: the target is a powertype of the source; a powertype is a
classifier whose objects are all the children of a given parent
refine: the source is at a finer degree of abstraction than the target use: the semantics of the source element depends on the semantics of the
public part of the target
Two Stereotypes of Dependency Among Use Cases: Cases: extend: the target use case extends the behavior of the source extend: include: the source use case explicitly incorporates the behavior of another include:
use case at a location specified by the source
System Use Case A
Actor
<<actor> > Actor
SalesPerson
<<include>><<include>>
<<include>>