Top Banner
Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013
25

Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Dec 18, 2015

Download

Documents

Kory Bradford
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Informática IIProf. Dr. Gustavo PatiñoMJ 16- 1812-09-2013

Page 2: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

An object is represented as rectangles with underlined names

: LecturerClass Name Only

Y.Welikala : LecturerClass and Object Name

Y.Welikala

Object Name Only

Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

Page 3: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

Intro to OO 201

Algebra 110

Electricity 100

Algorithms 202

ThermalDynamics 110

Electronics 110

English 101

Page 4: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

A class is represented using a compartmented rectangle.

Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

Lecturer

Page 5: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

LecturerName

save()change()

delete()

empID

create()

Page 6: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

The second and third sections may be suppressed if they need not be visible on the diagram

LecturerName

save()change()

delete()

empID

create()

LecturerName empID

Lecturer

save()change()

delete()

create()

Lecturer

Lecturer

Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

Page 7: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

CourseOffering

Intro to OO 201

Algebra 110

Algorithms 202

Electricity 101

Electronics 200

English 110

Thermo 110

Page 8: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

Class

Attribute

CourseOffering

numberstartTimeendTime

:CourseOfferingNumber=CS201

endTime=1230startTime=1030

Object

Attribute Value

:CourseOfferingNumber=CS202

endTime=1500startTime=1300

Page 9: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Attributes are in fact objects.However, fine detail such as date,

integer, etc., should not be modeled.Sometimes it is difficult to decide

whether an attribute should be an object, and vice versa, e.g. qualification as an attribute of person could be modeled as an object.

Page 10: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

The same operation (e.g. +) may apply to lots of different classes (polymorphism).

The implementation of an operation is called a method.

Methods are exactly equivalent to procedures and functions in traditional languages. Methods may have arguments. Methods may return a result.

Page 11: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

CourseOffering

addStudent

deleteStudent

getStartTime

getEndTime

Class

Operation

Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

Page 12: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Classes are types! Types are classes! Programming languages have built-in

classes, such as Real, Integer, Array. In an object language you can

expand and extend the types available, e.g. add complex numbers to the number hierarchy.

Page 13: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Association Aggregation Composition

Generalization

Page 14: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts

Train Carriage

Aggregation

WholePart

Informática II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

Page 15: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

A form of aggregation with strong ownership and coincident lifetimes The parts cannot survive the

whole/aggregate

Informática II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

Exam Paper

Aggregation

WholePart

Page 16: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Multiplicity defines how many objects participate in a relationships The number of instances of one class related

to ONE instance of the other class Specified for each end of the association

Associations and aggregations are bi-directional by default, but it is often desirable to restrict navigation to one direction If navigation is restricted, an arrowhead is

added to indicate the direction of the navigation.

Page 17: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

UnspecifiedExactly oneZero or more (many, unlimited)

One or moreZero or oneSpecified rangeMultiple, disjoint ranges

1

0..*

*

1..*

0..1

2..4

2,4..6

Page 18: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Student Schedule

Navigation

0..*1

Multiplicity

Informática II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

Page 19: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

A relationship among classes where one class shares the structure and/or behavior of one or more classes

Defines a hierarchy of abstractions in which a subclass inherits from one or more super classes Single inheritance Multiple inheritance

Generalization is an “is-a-kind of” relationship.

Page 20: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

One class inherits from another

BankAccountbalance

numbername

Withdraw()CreateStatement()

Current

Withdraw()

Savings

GetInterest()Withdraw()

Subclasses

Superclass

(parent)

Ancestor

Descendents

Generalization Relationship

Page 21: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

A class can inherit from several other classes

FlyingThing Animal

Airplane Helicopter Bird Wolf Horse

multiple inheritance

Page 22: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

A subclass inherits its parent’s attributes, operations, and relationships

A subclass may: Add additional attributes, operations,

relationships Redefine inherited operations (use caution)

Common attributes, operations, and/or relationships are shown at the highest applicable level in the hierarchy.

Page 23: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Order

Product

Ship via

Page 24: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Corporate Individual Truck Train

Sale

Salesperson Customer VehicleProduct

seller buyerItem sold

Shipping mechanism

Page 25: Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013.

Corporate Individual Truck Train Airplane

Suppose you need a new type of

shipping vehicle …

Suppose you need a new type of

shipping vehicle …

Sale

Salesperson Customer VehicleProduct

seller buyerItem sold

Shipping mechanism