Foundations: Language Mechanisms and Primitive OO Concepts Lecture 3: Introduction to OO Modeling E. Kraemer adapted from K. Stirewalt.

Slides:



Advertisements
Similar presentations
Dillon: CSE470: Object Modeling1 Requirements Model l Focus on WHAT, not HOW l Analyst needs to understand the problem »How does software fit into overall.
Advertisements

Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
Object-Oriented Analysis and Design
Improved software quality through semantic descriptions (Skutt) Karlstad University Dept. of Computer Science UML introduction A short introduction.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
NJIT 1 Domain Model Visualizing Concepts Chapter 9 Applying UML and Patterns Craig Larman.
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix.
1 CS1001 Lecture Overview Object Oriented Design Object Oriented Design.
Chapter 2: Entity-Relationship Model (Continued)
Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – ER Model.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Object-Oriented Analysis and Design
Objects What are Objects Observations
Chapter 9 Domain Models. Domain Model in UML Class Diagram Notation A “visual dictionary”
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
CSCI-383 Object-Oriented Programming & Design Lecture 9.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
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.
Introduction To System Analysis and Design
Object-Oriented Analysis and Design An Introduction.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
Structural Modeling. Objectives O Understand the rules and style guidelines for creating CRC cards, class diagrams, and object diagrams. O Understand.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Systems Analysis & Design 7 th Edition Chapter 5.
Class Modeling. Basic Class Modeling Concepts Object Class Link Association Generalization Inheritance.
Today in OOAD  The Domain Model Artifact UML Classes  EU-Bid Domain Model Exercise  EU-Lease Domain Model Assignment Guest Speaker  Kate Cunningham,
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
MCS 270 Spring 2014 Object-Oriented Software Development.
Engineering 5895: Software Design 9/11/01Class Diagrams 1.
Fall 2010 CS4310 Requirements Engineering A Brief Review of UML & OO Dr. Guoqiang Hu Department of Computer Science UTEP 1.
Object Modeling (1) Chapter 3 (1) Part 1: Modeling Concepts Object-Oriented Modeling and Design Byung-Hyun Ha
Lecture 6: Structural Modeling
Design? !… When it needs? To understand, to communicate with customers Complex problem What is good design? Separate What to do?(Policy) and How to do(mechanism)
Week III  Recap from Last Week Review Classes Review Domain Model for EU-Bid & EU-Lease Aggregation Example (Reservation) Attribute Properties.
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis: Associations. 2 Object Oriented Modeling BUAD/American University Class Relationships u Classes have relationships between each.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Relational Schema.
Foundations: Language mechanisms and primitive OO concepts Lecture 1: Classification and Inheritance Michigan State University Spring 2008 E. Kraemer Notes.
Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Mapping Objects ↔Relational DB. The Problem with Databases Databases store data in rows in tables, which are not like objects. We can simulate object.
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Appendix A Object-Oriented Analysis and Design A.1.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
Unified Modeling Language (UML)
WELCOME TO OUR PRESENTATION UNIFIED MODELING LANGUAGE (UML)
1 M206 Chapter 31: An Overview of Software Development 1.Defining the problem 2.Analyzing the requirement – constructing initial structural model 3.Analyzing.
Data Modeling Using the Entity- Relationship (ER) Model
Modeling with UML – Class Diagrams
Chapter 9 Domain Models.
Entity Relationship Model
Design Class Diagrams
Object-Oriented Analysis and Design
Object-Oriented Software Engineering Using UML, Patterns, and Java,
The OO Solution The OO model closely resembles the problem domain
Design Class Diagrams
Today’s Objectives Define the Problem Domain
UML Class Diagrams: Basic Concepts
Chapter 20 Object-Oriented Analysis and Design
ITEC 3220A Using and Designing Database Systems
Chapter 22 Object-Oriented Systems Analysis and Design and UML
Appendix A Object-Oriented Analysis and Design
Cheng (Sp2001): Object-Oriented Development Overview
Presentation transcript:

Foundations: Language Mechanisms and Primitive OO Concepts Lecture 3: Introduction to OO Modeling E. Kraemer adapted from K. Stirewalt

CSE335 2 Topics: –Need for abstraction in communicating and reasoning about designs –Brief introduction to UML notations –New modeling abstractions provided by UML

CSE335 3 Motivation: Reasoning about a design Goal: Be able to “reason about” a design –i.e., understand designer’s intent –Critique/improve the design Claim: Source code not best medium for communication and comprehension –Lots of redundancy and detail irrelevant for some program- understanding tasks –Especially poor at depicting relationships among classes in OO programs –To understand an OO design, one must be able to visualize these relationships Solution: Use abstract, visual representations

CSE335 4 Unified Modeling Language (UML) Collection of notations representing software designs from three points of view: –Class model describes the static structure of objects and relationships in a system Comprises object and class diagrams Provides new and very useful abstractions for reasoning –State model describes the dynamic aspects of objects and the nature of control in a system –Interaction model describes how objects in a system cooperate to achieve broader results Generally need all three models to describe a system No single model says everything

CSE335 5 Unified Modeling Language (UML) Collection of notations representing software designs from three points of view: –Class model describes the static structure of objects and relationships in a system Comprises object and class diagrams Provides new and very useful abstractions for reasoning –State model describes the dynamic aspects of objects and the nature of control in a system –Interaction model describes how objects in a system cooperate to achieve broader results Generally need all three models to describe a system No single model says everything

CSE335 6 UML class diagram notation Boxes denote classes Each box comprises: –Class name (e.g., Employee) –List of data attributes (e.g., first_name, last_name, etc). –List of operations (e.g., print) More compact than code and more amenable to depicting relationships among classes Employee first_name : string last_name : string hire_date : Date department : short print(ostream&) : void City cityName : string population : unsigned

CSE335 7 Abstraction in class diagrams Class diagrams often elide details: –Method associated with an operation –Attributes and operations may be elided in the diagram to improve readability Even if they exist in the C++ code Employee first_name : string last_name : string hire_date : Date department : short

CSE335 8 Object (or instance) notation Notes: –Attribute values are optional, as is ID. –Values not references to other objects No “embedded” objects No attributes of pointer or reference type ID : ClassName attribute = value...

CSE335 9 Example: Depicting an object doe : Employee first_name = “John” last_name = “Doe” hire_date = Sep:21:1998 department = 225

CSE Example: Depicting an object doe : Employee first_name = “John” last_name = “Doe” hire_date = Sep:21:1998 department = 225 object name class name

CSE Example: Depicting an object doe : Employee first_name = “John” last_name = “Doe” hire_date = Sep:21:1998 department = 225 attribute names attribute values

CSE Named vs. anonymous objects doe : Employee first_name = “John” last_name = “Doe” hire_date = Sep:21:1998 department = 225 : Employee first_name = “Mary” last_name = “Smith” hire_date = Oct:18:1980 department = 230 Employee doe(“John”, “Doe”, …); Employee* doe = new Employee(“John”, “Doe”, …); eList.addEmpl( new Employee(“Mary”, “Smith”, …) );

CSE More formal distinctions Value: Primitive “piece of data” –E.g., the number 17, the string “Canada” –Unlike objects, values lack identity Object: Meaningful concept or “thing” in an application domain –Often appears as a proper noun or specific reference in discussions with users. –May be attributed with values –Has identity that is not a function of its attributes

CSE Identity of values vs. objects = “Houston, TX” = “Houston, TX” : City cityName = “Houston, TX” population = : City cityName = “Houston, TX” population = 

CSE What’s the big deal about identity? Useful in reasoning about “goodness” of a design –Many poor designs result from an “encoding” of one object within another, using attribute values –By reasoning about identity, one may identify such a design flaw early –Best illustrated by example Also allows us to model relationships among objects and classes more explicitly

CSE Example: Travel-planning system City cityName : string population : unsigned timeZone : zone airportName : string airportCode : code Consider class City Question: Can you find a flaw in this design?

CSE Example: Travel-planning system City cityName : string population : unsigned timeZone : zone airportName : string airportCode : code Consider class City Question: Can you find a flaw in this design? Answer: These attributes “hiding” an object (i.e., an airport) that is meaningful in this domain

CSE Question Why might it be bad to encode one object as a collection of attribute values within another?

CSE Question Why might it be bad to encode one object as a collection of attribute values within another? Answers: –Potential for redundancy/inconsistency due to duplication some airports serve multiple cities some cities served by no airports some cities served by multiple airports –Operations over Airport objects may not need to know details associated with cities, such as population

CSE Design tip When designing a class: –Apply the identity test to each attribute (including attributes in combination) –Never use an attribute to model an “object identifier” UML notation helps enforce this discipline So then how do we model connections between objects, such as Cities and Airports?

CSE Relationships among objects Link: Physical or conceptual connection between objects –Much more abstract than pointers/references –Most (not all) links relate exactly two objects Association: Description of a group of links with common structure and semantics A link is an instance of an association: –Links connect objects of same classes –Have similar properties (link attributes) –Association describes set of potential links just as a class describes a set of potential objects

CSE Examples of links Houston : City cityName = “Houston, TX” population = HOU : Airport airportCode = HOU airportName = “Hobby” timeZone = Central IAH : Airport airportCode = IAH airportName = “Intercontinental” timeZone = Central Serves

CSE Example association City cityName : string population : unsigned Airport airportName : string airportCode : code timeZone : zone Serves 1..**

CSE Example association City cityName : string population : unsigned Airport airportName : string airportCode : code timeZone : zone Serves 1..** association name multiplicities

CSE New abstraction: Bidirectionality Links may be navigated in either direction! Benefits: –During early design, it is often difficult to predict the navigation directions that will be needed Especially true for many-to-many associations Better to model connections as bidirectional associations and later refine these associations into more implementation-level structures (e.g., pointers, vectors of pointers, maps, etc) –Often several ways to implement an association and the details are not salient to the “essence” of the design

CSE Example: Refinements of Serves association class City {... protected: string cityName; unsigned population; vector serves; }; class Airport {... protected: string airportName; CODE airportCode; ZONE timeZone; vector serves; }; class City {... protected: string cityName; unsigned population; }; class Airport {... protected: string airportName; CODE airportCode; ZONE timeZone; }; multimap cityServes; multimap airportServes;

CSE Design tip You should get comfortable with the various methods for refining a UML association –be able to easily switch back and forth between what is said in the diagram and what is allowable in the code –start to “think” using links/associations rather than pointers and references This is good training in abstraction

CSE New abstraction: Multiplicity constraints AB x..y w..z There are w to z B’s for each A There are x to y A’s for each B Goes with instance of this class x 0, 1, or specific number y 1, *, or specifc number * = “any number” Also: A specific list is acceptable. E.g., 2, 4, 6

CSE Common Multiplicity Idioms * 0..* “Optional” “At least one” “Any number”

CSE Object diagrams are “snapshots” Joe : Person Sally : Person Jill : Person Dating Joe : Person Sally : Person Jill : Person Dating Time T 1 Time T 2

CSE New abstraction: Generalization Employee first_name : string last_name : string hire_date : Date department : short Manager level : short group * 0..1 A.k.a. the “is-a” relation Relates class to one that is “more general” –Open arrow points to base class (i.e., the generalization) –Derived class inherits all attributes/operations of base class Relation is anti-symmetric and transitive

CSE Summary UML provides notations for modeling objects and classes of a system Diagrams denote models: –more abstract than implementations E.g., links vs. pointers E.g., associations describe collections of links –useful for explanation/documentation As we shall see, class models also useful prior to implementation

CSE Assignments … Blaha and Rumbaugh readings: –chapter 3 up through and including section 3.3 –chapter 4 up through and including section 4.2 Homework 1 – submit by midnight Monday via “handin” Homework 2 – practice with gdb