1 / 25

Graphical Representation for Object Oriented Analysis and Design

Graphical Representation for Object Oriented Analysis and Design. Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013. Representing Objects. An object is represented as rectangles with underlined names. : Lecturer. Class Name Only. Y.Welikala. Object Name Only.

ull
Download Presentation

Graphical Representation for Object Oriented Analysis and Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphical Representation for Object Oriented Analysis and Design Informática II Prof. Dr. Gustavo Patiño MJ 16- 18 12-09-2013

  2. Representing Objects • An object is represented as rectangles with underlined names : Lecturer Class Name Only Y.Welikala Object Name Only Y.Welikala : Lecturer Class and Object Name Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  3. Example: Objects English 101 Intro to OO 201 Electronics 110 Electricity 100 ThermalDynamics 110 Algebra 110 Algorithms 202 Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  4. Representing Classes • A class is represented using a compartmented rectangle. Lecturer Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  5. Class Compartments Lecturer Name empID create() change() save() delete()

  6. Class Compartments (cont.) • The second and third sections may be suppressed if they need not be visible on the diagram Lecturer Lecturer Lecturer Lecturer Name Name empID empID create() create() change() change() save() save() Lecturer delete() delete() Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  7. Example: Class Electricity 101 Intro to OO 201 Thermo 110 CourseOffering Algorithms 202 English 110 Algebra 110 Electronics 200 Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  8. What is Attribute? Object Class Attribute :CourseOffering Attribute Value Number=CS201 startTime=1030 endTime=1230 CourseOffering number startTime :CourseOffering endTime Number=CS202 startTime=1300 endTime=1500 Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  9. Attributes or objects? • 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.

  10. Operations and methods • 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.

  11. Operations and methods (2) Class CourseOffering addStudent deleteStudent getStartTime Operation getEndTime Informatica II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  12. Classes and Types • 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.

  13. Some Relationships of Object Orientation • Association • Aggregation • Composition • Generalization

  14. Relationship: Aggregation • A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts Part Whole Train Carriage Aggregation Informática II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  15. Relationship: Composition • A form of aggregation with strong ownership and coincident lifetimes • The parts cannot survive the whole/aggregate Part Whole Exam Paper Aggregation Informática II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  16. Association: Multiplicity and Navigation • 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.

  17. Association: Multiplicity • Unspecified • Exactly one • Zero or more (many, unlimited) • One or more • Zero or one • Specified range • Multiple, disjoint ranges 1 0..* * 1..* 0..1 2..4 2,4..6

  18. Example: Multiplicity and Navigation Multiplicity Student Schedule 1 0..* Navigation Informática II. Facultad de Ingeniería. Universidad de Antioquia. 2013-2

  19. Relationship: Generalization • 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.

  20. Example: Single Inheritance • One class inherits from another Ancestor BankAccount Superclass (parent) balance name number Generalization Relationship Withdraw() CreateStatement() Subclasses Current Savings Withdraw() GetInterest() Withdraw() Descendents

  21. Multiple Inheritance • A class can inherit from several other classes FlyingThing Animal multiple inheritance Airplane Helicopter Bird Wolf Horse

  22. What Gets Inherited? • 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.

  23. A simple Sales Order Example Order Product Ship via

  24. Class Diagram for the Sales Example Sale Shipping mechanism Item sold seller buyer Salesperson Customer Product Vehicle Truck Train Corporate Individual

  25. Effect of Requirements Change Suppose you need a new type of shipping vehicle … Sale Shipping mechanism Item sold seller buyer Salesperson Customer Product Vehicle Corporate Individual Truck Train Airplane

More Related