Chapter 3,Class Diagram.

Slides:



Advertisements
Similar presentations
Notice: Surgery Sessions (Weeks 6-10)
Advertisements

Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML, Part 4 UML 2 Metamodel.
Software analysis and design tools T120B pavasario sem.
Slides by Bruegee and Dutoit, Modified by David A. Gaitros COP 3331 Object Oriented Analysis and Design Chapter 2: Object Oriented Modeling using UML Jean.
Ch 12: Object-Oriented Analysis
Chapter 2, Modeling with UML, Part 2
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 5, Analysis: Object Modeling.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, UML ile Modelleme, Bölüm 2.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Using UML, Patterns, and Java Object-Oriented Software Engineering Requirements Analysis (Part 1 – Object Modeling)
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 5: Analysis, Object Modeling.
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Chapter 2, Modeling with UML
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 5, Analysis: Dynamic Modeling.
Feb. 13, 2001CSci Clark University1 CSci 250 Software Design & Development Lecture #9 Tuesday, Feb. 13, 2001.
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 1 UML First Pass: Class Diagrams Battery load()
Conquering Complex and Changing Systems Object-Oriented Software Engineering Art for Chapter 5, Analysis.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 5, Object Modeling.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
© Copyright Eliyahu Brutman Programming Techniques Course.
Using UML, Patterns, and Java Object-Oriented Software Engineering Modeling with UML Chapter 2 Object-Oriented Software Engineering: Using UML, Patterns,
1 Modeling with UML CMPE 131 Fall Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML.
COP 3331 Object-Oriented Analysis and Design 1 Modeling and UML  UML = Unified Modeling Language  Graphical Notation  Topics  Modeling  Basics of.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Introduction to Software Engineering ECSE-321 Unit 5 – Modeling with UML.
COP 3331 OBJECT-ORIENTED ANALYSIS AND DESIGN Bob Myers Department of Computer Science Week 6 Lecture.
SOFTWARE DESIGN RAJIKA TANDON
Modeling with UML Chapter 2 Object-Oriented Software Engineering: Using UML, Patterns, and Java, 2 nd Edition By B. Bruegge and A. Dutoit Prentice Hall,
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
UNB CS3013 Software Engineering II lectures adapted from Bernd Bruegge & Allen Dutoit, Object-Oriented Software Engineering: Conquering Complex and Changing.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 1 Object Modeling.
Chapter 2, Modeling with UML, Part 2
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML: Review Session (Optional)
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML: Review Session (Optional)
The Static Analysis Model Class Diagrams Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 1 Software Engineering September 19, 2001 UML.
Introduction to UML 임현승 강원대학교 Revised from the slides by Bernd Bruegge and Allen H. Dutoit for the book “Object-Oriented Software Engineering: Using UML,
Using UML, Patterns, and Java Object-Oriented Software Engineering More on UML Note: Slides are adapted by Linda Sherrell from the Software Engineering.
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 1 Software Engineering September 26, 2001 Analysis.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
UML Review Overview: modeling with UML  What is modeling?  What is UML?  Use case diagrams  Class diagrams  Sequence diagrams  Activity diagrams.
CEN 5011 Advanced Software Engineering
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 5, Analysis: Object Modeling.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 5, Analysis: Object Modeling.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Object Oriented Analysis System modeling = Functional modeling + Object modeling + Dynamic modeling Functional modeling = Use cases Object modeling =class.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 5, Analysis: Object Modeling.
1 Use Cases Object-Oriented Modeling and Design with UML (Second Edition) Blaha & Rumbaugh Sections 7.1, 8.1.
UML Review.
Modeling with UML Chapter 2
Chapter 2, Modeling with UML, Part 2
Chapter 2, Modeling with UML
Chapter 2: Modeling with UML - 2
UML Diagrams: Class Diagrams The Static Analysis Model
CS410 – Software Engineering Lecture #17: UML I
Chapter 2, Modeling with UML
Chapter 2, Modeling with UML
Domain Class Diagram Chapter 4 Part 2 pp
Chapter 2, Modeling with UML
Chapter 2, Modeling with UML
Chapter 2, Modeling with UML
CS410 – Software Engineering Lecture #9: UML
Chapter 2, Modeling with UML
Presentation transcript:

Chapter 3,Class Diagram

Outline of this Class Activity diagrams Class diagrams Describe the dynamic behavior of a system, in particular the workflow. Class diagrams Describe the static structure of the system: Objects, attributes, associations Use case diagrams Describe the functional behavior of the system as seen by the user Sequence diagrams Describe the dynamic behavior between objects of the system Statechart diagrams Describe the dynamic behavior of an individual object

Class Diagrams Class diagrams represent the structure of the system Used during requirements analysis to model application domain concepts during system design to model subsystems during object design to specify the detailed behavior and attributes of classes. Table zone2price Enumeration getZones() Price getPrice(Zone) TarifSchedule * Trip zone:Zone Price: Price

Classes Type Name Signature Attributes Operations Table zone2price Enumeration getZones() Price getPrice(Zone) TarifSchedule zone2price getZones() getPrice() TarifSchedule Name Attributes Operations Signature TarifSchedule A class represents a concept. A class encapsulates state (attributes) and behavior (operations): Each attribute has a type Each operation has a signature The class name is the only mandatory information

Instances An instance represents a phenomenon. zone2price = { {‘1’, 0.20}, {‘2’, 0.40}, {‘3’, 0.60}} tarif2006:TarifSchedule zone2price = { {‘1’, 0.20}, {‘2’, 0.40}, {‘3’, 0.60}} :TarifSchedule An instance represents a phenomenon. The attributes are represented with their values. The name of an instance is underlined. The name can contain only the class name (TarifSchedule) of the instance (anonymous instance).

Actor vs Class vs Object An entity outside the system to be modeled, interacting with the system (“Passenger”) Class An abstraction modeling an entity in the application or solution domain The class is part of the system model (“User”, “Ticket distributor”, “Server”) Object A specific instance of a class (“Joe, the passenger who is purchasing a ticket from the ticket distributor”).

Associations * Associations denote relationships between classes. Price Zone Enumeration getZones() Price getPrice(Zone) TarifSchedule TripLeg * Associations denote relationships between classes. The multiplicity of an association end denotes how many objects the instance of a class can legitimately reference.

1-to-1 and 1-to-many Associations Country name:String City 1 1-to-1 association Polygon draw() Point x: Integer y: Integer * 1-to-many association

Many-to-Many Associations Company * * StockExchange tickerSymbol

Aggregation An aggregation is a special case of association denoting a “consists-of / part-of / has-a” hierarchy. The aggregate is the parent class, the components are the children classes. Exhaust system Muffler diameter Tailpipe 1 0..2 A solid diamond denotes composition (“contains-a”): A strong form of aggregation where the life time of the component instances is controlled by the aggregate. That is, the parts don’t exist on their won (“the whole controls/destroys the parts”). TicketMachine ZoneButton 3

Difference of Aggregation and Composition Bir örnek Arabadır. Araba Parçalarından oluşur. Bu parçalara sahiptir. Eğer bir Parça yoksa araba bozuktur. Araba Parçalarıyla Composition oluşturur. Ayrıca Arabanın Yolcuları vardır. Yolcular Arabanın Parçası değildir. Eğer bir Yolcu yoksa Araba bozuk değildir. Araba Yolcularına sahip değildir. Arabada değillerse başka bir yerdedirler. İlişki geçicidir. Yolcular gelir ve gider. Araba ve Yolcular arasında Aggregation ilişkisi vardır. Her iki ilişki aslında Composition’dır. Arabanın hem Parçaları hem de Yolcuları vardır. Farklılık süresindedir. Parçalarla olan ilişki daimidir, Yolcularla olan ilişki geçicidir.

Without qualification Qualifiers Directory File filename Without qualification 1 * With qualification Directory File 1 filename 0..1 Qualification: A technique for reducing the multiplicity of associations by replacing many-to-many or one-to-many associations qith qualified associations. Qualified association: An association in which one end is indexed by an attribute. Qualifiers can be used to reduce the multiplicity of an association.

Qualification: Another Example Company * Lists * StockExchange tickerSymbol * StockExchange Company Lists 1 tickerSymbol

Inheritance Button ZoneButton CancelButton Inheritance is another special case of an association denoting a “kind-of” hierarchy. Inheritance simplifies the analysis model by introducing a taxonomy. The children classes inherit the attributes and operations of the parent class.

Packages Account Bank Customer Packages help you to organize UML models to increase their readability. Pretty much all UML elements can be grouped into packages. Thus, classes, objects, use cases, components, nodes, node instances etc. Can all be organized as packages. We can use the UML package mechanism to organize classes into subsystems Any complex system can be decomposed into subsystems, where each subsystem is modeled as a package. Account Bank Customer

Object Modeling in Practice Foo Amount CustomerId Deposit() Withdraw() GetBalance() Class Identification: Name of Class, Attributes and Methods Is Foo the right name?

Object Modeling in Practice: Brainstorming “Dada” Amount CustomerId Deposit() Withdraw() GetBalance() Foo Amount CustomerId Deposit() Withdraw() GetBalance() Account Amount CustomerId Deposit() Withdraw() GetBalance() Naming is important! Is Foo the right name?

Object Modeling in Practice: More classes Account Amount Deposit() Withdraw() GetBalance() Customer Name Bank Name CustomerId AccountId CustomerId 1) Find New Classes 2) Review Names, Attributes and Methods

Object Modeling in Practice: Associations Account Amount Deposit() Withdraw() GetBalance() Customer Name CustomerId AccountId Bank ? * * owns has 2 1) Find New Classes İçi dolu baklava: Composition. “Contains-a” ilişkisi. İçi boş baklava: Aggregation “has-a” ilişkisi. 2) Review Names, Attributes and Methods 3) Find Associations between Classes 4) Label the generic assocations 5) Determine the multiplicity of the assocations 6) Review associations

Practice Object Modeling: Find Taxonomies Account Amount Deposit() Withdraw() GetBalance() CustomerId AccountId Bank Name * Customer Name CustomerId() Has * Savings Account Withdraw() Checking Account Withdraw() Mortgage Account Withdraw() İçi dolu baklava: Composition. “Contains-a” ilişkisi. İçi boş baklava: Aggregation “has-a” ilişkisi. Taxonomy: Hiyerarşi yaratıp, sınıflandırma yapmak. Üçgenler: Inheritance. “Kind-of” ilişkisi.

Practice Object Modeling: Simplify, Organize Account Amount Deposit() Withdraw() GetBalance() CustomerId AccountId Show Taxonomies separately Savings Account Checking Account Mortgage Account İçi dolu baklava: Composition. “Contains-a” ilişkisi. İçi boş baklava: Aggregation “has-a” ilişkisi. Taxonomy: Hiyerarşi yaratıp, sınıflandırma yapmak. Üçgenler: Inheritance. “Kind-of” ilişkisi. Withdraw() Withdraw() Withdraw()

Practice Object Modeling: Simplify, Organize Customer Name CustomerId() Account Amount Deposit() Withdraw() GetBalance() CustomerId AccountId Bank Has * Use the 7+-2 heuristics or better 5+-2! İçi dolu baklava: Composition. “Contains-a” ilişkisi. İçi boş baklava: Aggregation “has-a” ilişkisi. Taxonomy: Hiyerarşi yaratıp, sınıflandırma yapmak. Üçgenler: Inheritance. “Kind-of” ilişkisi.

Practical Tips - 1 Simplicity Diagram layout Names References To be easier to understand/takes less effort Try to use minimal number of classes Diagram layout Draw diagrams in symmetric manner Try to avoid crossing lines Names Descriptive, crisp, unambiguous Singular nouns for the name of classes References Do not bury object references inside objects Model these as association

Practical Tips - 2 Generalization Association end names Do not nest subclasses too deeply Two or three levels deep is good Association end names To unify references to the same class Be alert for multiple uses of the same class Qualified associations To improve the precision of an association Challenge with a multiplicity of “many” Review Try to get others to review model Clarify names, improve abstraction, add info Documentation Diagram cannot describe the rationale Always document models

Review of Class Diagrams Multiplicity Inheritance Association End Name (Role) Class Aggregation Class diagrams represent the structure of the system

Class Diagram Examples - 1 - Çift taraflı bir bağıntı örneği -

Class Diagram Examples - 2

Class Diagram Examples - 3

Class Diagram Examples - 4

Class Diagram Examples - 5

Another view on UML Diagrams