Object-Oriented Modeling Using Modified Modeling Language (UML

)

Outline
‡ ‡ ‡ ‡ ‡ Unified Modeling Language Principles and Concepts Modeling Relations and Structures Modeling Dynamic Behavior Modeling Requirements with Use Cases
Object-Oriented Modeling Using UML 2

CS 3300 Object-Oriented Concepts

What is a Model?
A model is a simplification of reality. A model may provide
² blueprints of a system ² Organization of the system ² Dynamic of the system

CS 3300 Object-Oriented Concepts

Object-Oriented Modeling Using UML

3

Why We Model
´A successful software organization is one that consistently deploys quality software that meets the needs of its users. An organization that can develop such software in a timely and predictable fashion, with an efficient and effective use of resources, both human and material, is one that has sustainable business.µ
CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 4

Why We Model
‡ Model is built to
² Communicate the desired structure and behavior of the system ² Visualize and control the system·s architecture ² Better understand the system that being built ² Manage risk ² Expose opportunities for simplification and reuse

CS 3300 Object-Oriented Concepts

Object-Oriented Modeling Using UML

5

CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 6 .Why We Model ‡ We build models so that we can see and better understand the system we are developing.

² in providing a template that guides us in constructing a system. CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 7 .Importance of Modeling ‡ Models help us ² to visualize a system as it is or as we want it to be. ² in providing documenting the decisions we have made. ² to specify the structure or behavior of a system.

Every nontrivial system is best approached through a small set of nearly independent models. CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 8 . ‡ The best models are connected to reality. ‡ No single model is sufficient. ‡ Every model may be expressed at different levels of precision.Principles of Modeling ‡ The choice of what models to create has a major influence on how a problem is approached and how a solution is shaped.

Objected-Oriented Modeling ‡ Two most common ways in modeling software systems are ² Algorithmic ‡ Procedures or functions ² Object oriented ‡ Objects or classes CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 9 .

What is UML? ‡ UML is a language for ² ² ² ² Visualizing Specifying Constructing Documenting CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 10 .

tie things together ‡ Diagrams -.Building Blocks of UML ‡ Things -.group interesting collections of things CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 11 .abstraction ‡ Relations -.

Principles and Concepts ‡ Objects and Classes ‡ Principles CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 12 .

Objects and Classes Interpretation in the Real World Interpretation in the Model Object An object is a thing that can be distinctly identified. A class characterizes the structure of states and behaviors that are shared by all instances. This objects are called the instances of the class. An object has an identity. a state. Class A class represents a set of objects with similar characteristics and behavior. and a behavior. CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 13 .

‡ Each method has a name.Objects ‡ Each of object has a unique identity. a type. ‡ Each field has a name. and a value. a type. or attributes. ‡ Each method may or may not return a value. ‡ Features are a combination of the state and the behavior of the object. CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 14 . and a value. ‡ Behaviors are defined by methods. ‡ The state of an object is composed of a set of fields (data fields).

CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 15 . ‡ Objects can be mutable or immutable. ‡ The values of the fields are mutable. ‡ Methods that modify the state of the object are called mutators.Properties of Objects ‡ Two objects are equal if their states are equal. ‡ Two objects are identical if they are the same objects. ‡ Methods that do not modify the state of the object are called accessors.

and semantics. ‡ A class is a description of a set of objects that share the same attributes. CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 16 . operations. relationships.Classes ‡ A class defines a template for creating or instantiating its instances or objects.

‡ The implementations of methods are defined in the class definition and fixed for a given object. ‡ Different instances of the class may have different states. ‡ Each instance of the class has its own state.Classes ‡ A class defines -² the names and types of all fields ² the names. ‡ Values of methods are immutable CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 17 . implementations of all methods ‡ The values of the fields are not defined or fixed in the class definition. types. ‡ The values of the fields are mutable.

y. Method: move public void move (int dx. int dy){ // implementation } CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 18 .Example Class name: Point class Point { Fields: x. y int x.

UML Notation for Classes ClassName field1 « fieldn method1 « methodm The top compartment shows the class name. The bottom compartment contains the declarations of the methods Object-Oriented Modeling Using UML 19 CS 3300 Object-Oriented Concepts . The middle compartment contains the declarations of the fields of the class.

all the classes in the same package.Field Declaration ‡ The name of the field is required in the field declaration. ² Package -.the feature is accessible to any class ² Protected -.the feature is only accessible within the class itself. ‡ Field declaration may include: [Visibility][Type]Name[[Multiplicity]][=InitialValue] [Visibility]Name[[Multiplicity]][:Type][=InitialValue] ‡ Visibility or accessibility defines the scope: ² Public -. CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 20 .the feature is accessible to the class itself and all classes in the same package.the feature is accessible to the class itself. and all its subclasses. ² Private -.

Visibility syntax in Java and UML Visibilty public protected package private private Java Syntax public protected UML Syntax + # ~ - CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 21 .

.MAX_Size]:Student CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 22 ..Examples Java Syntax Date birthday UML Syntax Birthday:Date Public int duration = 100 +duration:int = 100 Private Student students[0.MAX_Size] -students[0.

Type Name CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 23 .Method Declaration ‡ The name of the method is required in the method declaration. ..])[:Type] ‡ Each parameter of a method can be specified by -. ..]) [Visibility]Name([Parameter.. ‡ Method declaration may include: [Visibility][Type]Name([Parameter..

int dy) public int getSize() +int getSize() CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 24 . int dy) UML Syntax ~move(int dx.Examples Java Syntax void move(int dx.

int dy) move() CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 25 .dy:int) Point x y public void move(int dx.Example Point Point -x:int -y:int private int x private int y +move(dx:int.

CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 26 .objectName whose class is of no interest :ClassName -.UML Notation for Object ObjectName : ClassName field1 = value1 « fieldn = valuen The top compartment shows the object name and its class. objectName -. The bottom compartment contains a list of the fields and their values.anonymous object of ClassName which can be identify only through its relationship with other object.

x = 24. CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 27 . P1:Point Point p1 = new Point().y = 0. x = 0 y = 0 p1.Examples P1:Point Point p1 = new Point().x = 0. P1. P1. x = 24 y = 40 p1.y = 40.

Message Passing or Method Invocation ‡ Objects communicate with one another through message passing. ‡ A message represent a command sent to an object -.recipient ‡ A message consists of the receiving object. CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 28 . the method to be invoked and the arguments to method.

move(10.20) CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 29 .20) Method move() Arguments (10.Example Recipient p1 p1.

swing.emporia.awt.* CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 30 .mathbeans.Packages ‡ Package name are in lower case -Java.emporia.* ‡ Packages that will be widely used should be named as the reverse of the internet domain as the prefix of the package name EDU.event javax.MathTable EDU.mathtools.

UML notation of packages CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 31 .

Principles ‡ Modularity: ² alleviate complexity of large-scale systems ‡ Abstraction: ² separating the essential from the non-essential characteristics of an entity ‡ Encapsulation: ² Information hiding ‡ Polymorphism: ² Portability ‡ Levels of Abstraction: ² Organization of classes and interfaces CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 32 .

functional relatedness of the entities within modules. ² Coupling ² inter-dependency among different modules. ² Cohesion -. ‡ Each module is relatively small and simple ‡ Interactions among modules are relatively simple ‡ hierarchical CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 33 .Principle of Modularity ‡ A complex software system should be decomposed into a set of highly cohesive but loosely coupled modules. ‡ The basic for decomposition are cohesion and coupling.

‡ The complexity of the module is hidden from the clients. CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 34 .Principle of Abstraction ‡ The behaviors or functionalities should be precisely characterized as contractual interface which captures the essence of the behavior.

‡ Information hiding CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 35 .Principle of Encapsulation ‡ The implementation of a module should be separated from its contractual interface and hidden from the clients of the module.

Principle of Polymorphism ‡ Ability to interchange modules dynamically without affecting the system. ‡ refers to a contractual interface with multiple interchangeable implementation CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 36 .

extension and implementation ² Association -.aggregation and compostion ² Dependency CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 37 .Modeling Relationships and Structures ‡ A class diagram consists of ² A set of nodes that represent classes and interfaces ² A set of links represent relationships among classes ‡ Class diagrams can be used to model: ² Inheritance -.

Inheritance ‡ Define a relationship among classes and interfaces ‡ Inheritance model -.the is-a(n) relationship CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 38 .

Example CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 39 .

Principle of Levels of Abstraction ‡ Abstractions can be organized into different levels. ‡ Higher level is more general CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 40 .

Association ‡ Association represents binary relationship between classes Student advisee * * enroll * Course * teach 1 adviser CS 3300 Object-Oriented Concepts 1 Faculty 41 Object-Oriented Modeling Using UML .

Aggregation and Compositon ‡ Aggregation is a special form of association ² Has-a or part-whole relationship ‡ Composition is a stronger form of aggregation CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 42 .

* Faculty CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 43 ..Example University 1 * College 1 * Department 1 * Student 1 Chairman-of 1 1 Member-of 1.

CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 44 .Dependency ‡ Dependency is a relationship between entities such that the proper operation of one entity depends on the presence of the other entity. and changes in one entity would affect the other entity.

Course c) void removeCourse(CourseSchedule Course findCourse(String title) void enroll(Course c. Student s) void drop(Course c.Example CourseSchedule Registrar void addCourse(CourseSchedule a. Student s Course Student CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 45 .

Modeling Dynamic Behavior ‡ Sequence diagram ² Depict object interaction by highlighting the time ordering of method invocation CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 46 .

Example CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 47 .

Modeling Dynamic Behavior ‡ State diagram ² Depict the flow of control using the concepts of state and transitions ² Labels of transitions are in the form: [Event-List][[Guard]][/Action] .Entry action and exit action entry/Action1 exit/Action2 CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 48 .

Graphical notations CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 49 .

Modeling Dynamic Behavior ‡ Nested state diagram ² Composite of state diagrams CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 50 .

Example talk CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 51 .

Actors.Modeling Requirements with Use Cases ‡ Use cases describes the externally observable behavior of system functions in the form of interactions between the system to be developed and the external entities -. ‡ Consist of a name and scenarios ‡ One of scenarios is the main scenario CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 52 . ‡ Actors may represent roles played by users of the system or other systems.

Use Case Diagram ‡ Consist of: ² Use cases ² Actors ² Relationships among actors and use cases CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 53 .

Extension relationships among actors CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 54 .

Dependency relationships among use cases CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 55 .

CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 56 .Case Study: An E-Bookstore ‡ Problem requirements ‡ Program specifications ‡ Object models ² Identifying classes ² Identifying the features of classes -states and behaviors ² Identifying relationships among classes ² inheritance and interfaces.

music CDs. and computer software CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 57 .Requirements ‡ Allow customers to browse and order books.

and software ‡ Provide a functionality for customers registration as well as updating customer·s information ‡ Provide a functionality for ordering and shipping ‡ Provide a functionality for updating inventory CS 3300 Object-Oriented Concepts Object-Oriented Modeling Using UML 58 . CDs.Specifications ‡ Provide information on the books.

Register Logon Manager Customer Shop Manage catalog Catalog Manager Manage Acount System administrator CS 3300 Object-Oriented Concepts Process order Inventory manager Object-Oriented Modeling Using UML 59 .

Sign up to vote on this title
UsefulNot useful