Objects and Classes OO model an approximate interpretation of real world – Objects represent real world entities which have identities, states and behaviors.

Slides:



Advertisements
Similar presentations
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall A.1.
Advertisements

UML Class and Sequence Diagrams Violet Slides adapted from Marty Stepp, CSE 403, Winter 2012 CSE 403 Spring 2012 Anton Osobov.
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Unified Modeling Language Sequence Diagrams Chapter 2 (JIA)
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Object-Oriented.
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
UML – Class Diagrams.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 14 (Web): Object-Oriented Data Modeling
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Unified Modeling Language (UML)
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix.
Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra,
1 Object-Oriented Modeling Using UML CS 3331 Fall 2009.
Chapter 14: Object-Oriented Data Modeling
Unified Modeling Language
Object-Oriented Analysis and Design
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented Design.
Systems Analysis and Design in a Changing World, Fifth Edition
UML Unified Modeling Language. What is UML? Unified Modeling Language (UML) is a standardized, general-purpose modeling language in the field of software.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Copyright 2001 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix A Object-Oriented.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
Object-Oriented Modeling Using Modified Modeling Language (UML)
Object-Oriented Modeling Using Modified Modeling Language (UML)
Object-Oriented Modeling Chapter 10 CSCI CSCI 1302 – Object-Oriented Modeling2 Outline The Software Development Process Discovering Relationships.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Chapter 9 Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
CHAPTER 13 (ONLINE): OBJECT-ORIENTED DATA MODELING © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
1 © Prentice Hall, 2002 Chapter 14: Object-Oriented Data Modeling Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 15: Object-Oriented Data Modeling Modern Database Management 9 h Edition Jeffrey A.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 13 (Online): Object-Oriented Data Modeling Modern Database Management 10 th Edition.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
1 Class Diagrams: Advanced Concepts. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are the most commonly used diagrams.
Fall 2010 CS4310 Requirements Engineering A Brief Review of UML & OO Dr. Guoqiang Hu Department of Computer Science UTEP 1.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Design Model Lecture p6 T120B pavasario sem.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Object Oriented Analysis and Design Class and Object Diagrams.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Object-Oriented Programming Chapter Chapter
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 11 Object-Oriented.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
Chapter 3: Introducing the UML
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Appendix A Object-Oriented Analysis and Design A.1.
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Basic Characteristics of Object-Oriented Systems
Cmpe 589 Spring 2006.
Object-Oriented Modeling
Object-Oriented Analysis and Design
Class Diagrams.
Chapter 11 Object-Oriented Design
Object Oriented Analysis and Design
Software Engineering Lecture #11.
Chapter 20 Object-Oriented Analysis and Design
Appendix A Object-Oriented Analysis and Design
Copyright 2007 Oxford Consulting, Ltd
Object Oriented System Design Class Diagrams
Appendix A Object-Oriented Analysis and Design
Appendix A Object-Oriented Analysis and Design
Presentation transcript:

Objects and Classes OO model an approximate interpretation of real world – Objects represent real world entities which have identities, states and behaviors – Classes are sets of objects with similar characteristics and behaviors (collectively  features) Setters & Getters (or Mutators and Accessors) Immutable objects – State never changes – No mutators Object equality and “identical”ity

OO Development Principles (MAEP) Modularity – Intended to control complexity of larges-scale systems through divide-and-conquer – A complex system should be decomposed into a set of highly cohesive but loosely coupled modules (classes/packages) Cohesion: relatedness among the entities within a single module Coupling: interdependency among modules

OO Development Principles (MAEP) Abstraction – The behavior of a module should be characterized in a precise YET succinct description known as the contractual interface of the module – Described module = Service provider – Other modules = clients – contractual interface = service contract between the two Describes only the what and not the how Clients only understand contract and not the complex services (complexity is hidden)

OO Development Principles (MAEP) Telephone service: signals very complex routing & connecting calls converting voice to electronic signals converting from analog to digital and vice versa Encryption/decryption – Yet we are unaware … just know how to dial (phone manual  contract)

OO Development Principles (MAEP) Encapsulation – Complements abstraction – Clients need know nothing other than contract – The implementation of a module should be separated from its contractual interface and hidden from the clients of the module – Information hiding to reduce coupling among modules The less the clients know, the less the coupling  modification of implementation becomes easier without affecting clients

OO Development Principles (MAEP) E.g. Telephone service – Signals used to be transferred in analog mode, now digital is used with encryption – Yet, we still dial in the same way

OO Development Principles (MAEP) Polymorphism – Contractual interfaces can have multiple interchangeable implementations – Several service providers can honor the same contractual interface – The ability to interchange modules (implementations) dynamically without affecting the clients

OO Development Principles (MAEP) E.g. Telephone service – Digital cellular service uses advanced technologies but has smaller service regions compared to analog service – An analog/digital dual-mode cellular phone is an example of polymorphism – Provide a single interface for using the phone but employs two different technologies to provide the service – We are not aware of it

UML Notation for Classes MS Visio  Software  UML Model Diagram  UML Static Structure Class Point{ private int x, y; public void move(int dx, int dy){…} } Point X Y move(dx, dy)

Visibility VisibilityJava UML Public Public + Protected Protected # Package * ~ Private Private -

UML Notation for Objects Point p1 = new Point(); p1.x = 0; p1.y = 0; Point p2 = new Point(); p2.x = 24; p2.y = 40; p1: Point X = 0 Y = 0 p2: Point X = 24 Y = 40

UML Notation for Classes Class is a rectangle with three portions – Class name – Class variables – Class methods – Underline static variables and methods Names of abstract classes are in Italics Names of Interfaces are enclosed in > Message Passing  communication among objects Class x calls p1.move(10,20) – Recipient p1 – Method move() – Arguments (10,20)

Modeling Static Structures Class diagrams – Nodes representing classes and interfaces – Links representing relationships among classes Inheritance (extension and implementation) Association (and aggregation and composition) Dependency

Inheritance is-a relationship: every instance of sub is an instance of super – Class extension Reusing and sharing the implementation (fields and methods) of superclass by subclass specialization/generalization in UML – Interface extension Expansions of the service contract specialization/generalization in UML – Implementation No reuse but rather implementation of a contractual interface by a class realization in UML

Inheritance in UML Superclass Subclass > Implementation Class

Inheritance Multiple Inheritance – Available in C++ – Restricted form in Java Extend 1 class Implement many interfaces – Interfaces don’t exist, per se, in C++

Associations 0..*

Associations Specify binary relationships between classes – Either one or both participating classes contain references to the other Unidirectional or Bidirectional – Instance variables holding references to other classes – Direction tells us which class references the other (referencing to referenced) Association – Solid line – Name or label with direction (In VISIO: if you can’t see name then, right click  Shape Display Options  Check Name & Properties buttons) OR role names (good for recursive associations) – Association Multiplicity – navigation of association (if known…from referencing to referenced) Default: bi-directional

Associations – Unidirectional associations Shown with an arrow at one end The class from which the arrow is originating has an instance variable base on the class at the other end of the arrow – Bidirectional associations No arrows Each class has an instance variable based on the other – multiplicity l..u, i, or * 1 as a lower bound? – Total participation of class 0 as a lower bound? – Partial participation of class

Aggregation & Composition Special form of association that represents has-a or part-of relationships Used to distinguish the whole from the part Composition (parts can’t exist on their own) is a stronger form of aggregation (parts can exist on their own) 0..*

Aggregation & Composition Aggregation occurs when a class is a collection or container of other classes, but where the contained classes do not have a strong life cycle dependency on the container – essentially, if the container is destroyed, its contents are not – clear diamond shape – Parts can be shared by multiple “whole”s Composition indicates a strong life cycle dependency between instances of the container class and instances of the contained class(es) – If the container is destroyed, any contained are also destroyed – black diamond shape – Parts can’t be shared by multiple “whole”s

Aggregation & Composition Composition – Parts participate totally in the whole Aggregation – Parts participate partially in the whole Both are implemented as an instance variable of the part in the whole – (sometimes) in addition to an instance variable of the whole in the part for convenience (composition) 0..*

Aggregation & Composition 1 1..* 0..* 0..1

Dependency The operation of one object depends on the presence of the other entity  changes in one would affect the other A depends on B if A – uses B as a method parameter, local method variable, or method return type – uses any of B’s static methods or variables Dashed line from A to B (dependent to provider) with the head pointing towards B (provider)

Dependency

Identifying Classes UML in VISIO Underline verbs and nouns in use cases AND requirements – Nouns  classes or attributes – Verbs & action nouns  class methods

Modeling Dynamic Behavior Class diagrams model the static structure of the system Use cases capture user requirements (functional ones only) Here we are concerned with details about functionalities – Actions done by/on objects – Interactions among objects – Order of events Sequence Diagrams – Depict object interaction by highlighting the time ordering of method invocations – Y-axis represents time – X-axis contains the objects involved in the interaction as columns with the object initiating the interaction being the leftmost

Sequence Diagram i.e., duration one of the methods of the object is executing

Printing a document PrintingExample.vsd

Additional Examples One Minute Microwave.docx exercise Example from Practical Object-Oriented Development with UML and Java---Chapter 7 – Scenario 1: Warm food for 1 minute – Scenario 2: Warm food for 1 minute and then add a another minute as food is cooking (i.e., before 1 st minute finishes) – Scenario 3: Warm food for less than 1 minute (i.e. remove food before timer times out)