Object Oriented Analysis and Design Using the UML
Object Oriented Analysis and Design Using the UML
Basic Concepts of Object Orientation n n n n Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
What is an Object? n Informally, an object represents an entity, either physical, conceptual, or software q Physical entity Truck q Conceptual entity Chemical Process q Software entity Linked List
A More Formal Definition n n An object is a concept or thing with sharp boundaries and meaning for an application An object is something that has: q q q State Behavior Identity
Representing Objects n An object is represented as rectangles with underlined names Professor Class Name Only : Professor LAL Object Name Only
What is a Class? n A class is a description of a group of objects with same properties (attributes), behavior (operations), relationships, and semantics q An object is an instance of a class OO Principle: Abstraction
Sample Class Course Properties Name Location Days offered Credit hours Start time End time a + b = 10 Behavior Add a student Delete a student Get course roster Determine if it is full
Representing Classes n A class is represented using a compartmented rectangle Professor a + b = 10 Professor Simran
Class Compartments n A class is comprised of three sections q q q The first section contains the class name The second section shows the structure (attributes) The third section shows the behavior (operations) Class Name Attributes Operations Professor name emp. ID create( ) save( ) delete( ) change( )
What is an Attribute? Object Class Attribute Value : Course. Offering number = 101 start. Time = 900 end. Time = 1100 number start. Time end. Time : Course. Offering number = 104 start. Time = 1300 end. Time = 1500
What is an Operation? Course. Offering Class Operation add. Student delete. Student get. Start. Time get. End. Time
What is a Package? n n A package is a general purpose mechanism for organizing elements into groups A model element which can contain other model elements Package Name n OO Principle: Modularity Package is rendered as a tabbed folder including name and sometimes, its contents.
Basic Concepts of Object Orientation n n n n Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
Relationships n Association q q n n Aggregation Composition Dependency Generalization
Relationships: Association n Models a semantic connection among classes Association Name Professor Works for Association Class University Role Names University Professor Employee Employer
Association n Association represents binary relationship between classes Student advisee * * enroll * Course * teach 1 adviser 16 1 Faculty
Relationships: Aggregation n A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts Whole Part Schedule Student Aggregation
Aggregation and Compositon n Aggregation is a special form of association q n 18 Has-a or part-whole relationship Composition is a stronger form of aggregation
n A form of aggregation with strong ownership and coincident lifetimes q The parts cannot survive the whole/aggregate Part Whole Schedule Student Aggregation
Association: Multiplicity and Navigation n Multiplicity defines how many objects participate in a relationships q 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 q If navigation is restricted, an arrowhead is added to indicate the direction of the navigation q n
Association: Multiplicity n n n n 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
Example: Multiplicity and Navigation Multiplicity Student 1 Navigation 0. . * Schedule
Example University 1 * College 1 * Department * Student 1 1 1 Member-of 1. . * Chairman-of Faculty 23 1
Relationships: Dependency n A relationship between two model elements where a change in one may cause a change in the other. Client Class Package Client. Package Supplier Dependency relationship Component Supplier Client Supplier. Package Dependency relationship
n 25 Dependency is a relationship between entities such that the properation of one entity depends on the presence of the other entity, and changes in one entity would affect the other entity.
Relationships: Generalization n n A relationship between superclass and subclass. Defines a hierarchy of abstractions in which a subclass inherits from one or more superclasses. q q n Single inheritance Multiple inheritance Generalization is an “is-a-kind of” relationship
Example: Single Inheritance n One class inherits from another Ancestor Superclass (parent) Account balance name number Withdraw() Create. Statement() Generalization Relationship Subclasses Checking Savings Withdraw() Get. Interest() Withdraw() Descendents
Example: Multiple Inheritance n A class can inherit from several other classes Flying. Thing Animal multiple inheritance Airplane Helicopter Bird Wolf Horse Use multiple inheritance only when needed, and always with caution !
Example: What Gets Inherited Ground. Vehicle Superclass (parent) weight license. Number owner 0. . * Person 1 register( ) generalization Subclass Car size Truck tonnage get. Tax( ) Trailer
UML Unified Modeling Language 30
What is UML? n UML is a language for q q 31 Visualizing Specifying Constructing Documenting
Building Blocks of UML n n n 32 Things -- abstraction Relations -- tie things together Diagrams -- group interesting collections of things
To view the static parts of a system using one of four following diagrams: n Class diagrams q n Object diagrams q n To represent different components Deployment diagrams q 33 To represent Objects Component diagrams q n To represent classes and interfaces To represent different nodes of the system
To view the dynamic parts of a system using one of five following diagrams: n Use Case Diagrams q n Sequence Diagrams q n Focused on the changing state of the system driven by events Activity Diagrams q 34 Focused on the structural organization of objects that send and receive messages State Chart Diagrams q n Focused on the time ordering of messages Collaboration Diagrams q n Organizes the behavior of the system Focused on the flow of control from activity to activity
Use Case Diagrams 35
n n v § § § It models dynamic aspects of system. Shows set of use cases , actors and their relationships. Contents Use cases Actors relationships
Use Case Diagrams n n 37 Use Case diagrams show the various activities the users can perform on the system. They model the dynamic aspects of the system.
Use Case Diagrams n A set of ACTORS : roles users can play in interacting with the system. q n A set of USE CASES: each describes a possible kind of interaction between an actor and the system. q n Uses cases are actions that a user takes on a system A number of RELATIONSHIPS between these entities (Actors and Use Cases). q 38 An actor is used to represent something that users our system. Relationships are simply illustrated with a line connecting actors to use cases.
Use Case Diagrams - Actors n n An actor is a user of the system playing a particular role. Actor is shown with a stick figure. employer 39 employee client
Use Case Diagrams – Use Cases n n n Use case is a particular activity a user can do on the system. Is represented by an ellipse. Following are two use cases for a library system. Borrow 40 Reserve
Use Case Diagram for Student Assessment Management System Grade system Recor d grade s View grades Teacher Distribute Report cards Create report cards 41 Student Printing administrator
University Record System (URS) n n A University record system should keep information about its students and academic staff. Records for all university members are to include their id number, surname, given name, email, address, date of birth, and telephone number. q n In addition to the attributes mentioned above: q q 42 Students and academic staff each have their own unique ID number: stud. N (students), acad. N (academic employee), where N is an integer (N>0). Students will also have a list of subjects they are enrolled in. A student cannot be enrolled in any more than 10 subjects. Academic employees will have a salary, and a list of subjects they teach. An academic can teach no more than 3 subjects.
Some Actions Supported by URS n The system should be able to handle the following commands. q q 43 Add and remove university members (students, and academic staff) Add and Delete subjects Assign and Un-assign subjects to students Assign and Un-assign subjects to academic staff.
Use Case Diagram - URS System URS add member system user del member add subject academic del subject assg subject unass subject enrol subject 44 unenrol subject student
- Slides: 44