Download presentation
Presentation is loading. Please wait.
Published byMarion Randall Modified over 8 years ago
1
Object-Oriented Paradigm and UML1 Introduction to the Object- Oriented Paradigm
2
Object-Oriented Paradigm and UML2 Objectives To explain the essential difference between the procedural and object- oriented (OO) paradigms To summarize the advantages and disadvantages of the OO paradigm To explain the basics concepts of the OO paradigm: objects, classes, attributes, and operations
3
Object-Oriented Paradigm and UML3 The Procedural Paradigm Operations are separate from data but manipulate it. Example: A stack data type –Data store (array, linked list) –Separate operations for pushing, popping, etc.
4
Object-Oriented Paradigm and UML4 The Object-Oriented Paradigm Data is packaged (encapsulated) with the operations that manipulate it. Example: a stack object –Data store within a stack object –Operations within the stack object
5
Object-Oriented Paradigm and UML5 Encapsulation Advantages 1 Problem and solution similarity— Software objects are like real-world things. Abstraction—Data structures and algorithm details are ignored in design. Information hiding—Implementations can be truly hidden. (Shielding the internal details of a program unit’s processing from other program units)
6
Object-Oriented Paradigm and UML6 Encapsulation Advantages 2 Coupling—Operations are not related through shared data structures. (The degree of connection between pairs of modules) Cohesion—It’s easier to keep related operations and data together. (The degree to which a module’s parts are related to one another)
7
Object-Oriented Paradigm and UML7 Encapsulation Advantages 3 Reusability—It’s easier to reuse objects than collections of operations and various data structures. Scalability—Objects can be of arbitrary size. New features—The object-oriented paradigm offers new and powerful ways of doing things, as we will see.
8
Object-Oriented Paradigm and UML8 Problems with the OO Paradigm It’s a lot more complicated than the procedural paradigm. –Harder to learn –Harder to use properly
9
Object-Oriented Paradigm and UML9 Objects An object is an entity that has properties and exhibits behavior. Things are encapsulated when they are packaged together in a container. Objects encapsulate properties and behavior. Ideally, objects model things in the world. –Example: Traffic simulation
10
Object-Oriented Paradigm and UML10 Attributes and Operations An attribute is a named data value held by an object or a class. An operation is a named object or class behavior. A feature is an attribute or operation. An attribute is a named data value held by an object or a class. An operation is a named object or class behavior. A feature is an attribute or operation.
11
Object-Oriented Paradigm and UML11 Attribute and Operation Examples
12
Object-Oriented Paradigm and UML12 Object Characteristics Every object has its own attributes and operations, though these may be the same as some other objects. Every object has a unique identity. –Two objects with the same attributes holding the same values and behaviors are distinct.
13
Object-Oriented Paradigm and UML13 Messages Objects communicate by sending one another messages. Messages are abstractions of function calls, signals, exceptions, etc. Ideally, objects send messages that model real-world communications between things. –Example: Traffic simulation
14
Object-Oriented Paradigm and UML14 Classes Classes have attributes and operations. A class is not a set of objects—it is more like a blueprint or a specification. Objects are said to be instances of classes. An class is an abstraction of a set of objects with common attributes and operations.
15
Object-Oriented Paradigm and UML15 Examples of Classes
16
Object-Oriented Paradigm and UML16 Classes and Abstract Data Types ADT: a set of values (the carrier set) and a collection of operations to manipulate them A class forms a type but not an ADT Mathematical entities that can be implemented procedurally or using the OO paradigm OO techniques provide an excellent way to implement ADTs
17
Object-Oriented Paradigm and UML17 UML Class and Object Diagrams
18
Object-Oriented Paradigm and UML18 UML Unified Modeling Language Developed by Grady Booch, Ivar Jacobson, and James Rumbaugh (the three amigos) at Rational Software Corporation (1994) –Goal to produce a standard OO analysis and design notation Now a standard controlled by the Object Management Group (OMG)
19
Object-Oriented Paradigm and UML19 UMLUML Names A name in UML is character string that identifies a model element. –Simple name: sequence of letters, digits, or punctuation characters –Composite name: sequence of simple names separated by the double colon (::) Examples –Java::util::Vector –veryLongNameWithoutPunctuationCharacters –short_name
20
Object-Oriented Paradigm and UML20 UML Class Symbol
21
Object-Oriented Paradigm and UML21 Attribute Specification Format name : type [ multiplicity ] = initial-value name—simple name, cannot be suppressed type—any string, may be suppressed with the : multiplicity—number of values stored in attribute –list of ranges of the form n..k, such that n <=k –k may be * –n..n is the same as n –0..* is the same as * –1 by default –if suppressed, square brackets are omitted initial-value—any string, may be suppressed along with the =
22
Object-Oriented Paradigm and UML22 Examples weight weight : real = 40.0 signal[*] : real = { 0.0 } charge[3,5,7..10] hour = 12
23
Object-Oriented Paradigm and UML23 Operation Specification Format name( parameter-list ) : return-type-list name—simple name, cannot be suppressed parameter-list –direction param-name : param-type = default-value –direction—in, out, inout, return; in when suppressed –param-name—simple name; cannot be suppressed –param-type—any string; cannot be suppressed –default-value—any string; if suppressed, so is = return-type-list—any comma-separated list of strings; if omitted (with :) indicates no return value The parameter-list and return-type-list may be suppressed together.
24
Object-Oriented Paradigm and UML24 Examples rotate() rotate( degrees : real ) rotate( in degrees : real = 0.0 ) : Boolean rotate( inout degrees : real ) print( s : String[*] ) : void split( s : String ) : int, String[*]
25
Object-Oriented Paradigm and UML25 Attribute and Operation Examples
26
Object-Oriented Paradigm and UML26 Class Diagram Uses Central static modeling tool in object- oriented design Can be used throughout both the product and engineering design processes
27
Object-Oriented Paradigm and UML27 Object Diagrams Object diagrams are used much less often than class diagrams. Object symbols have only two compartments: –Object name –Attributes (may be suppressed)
28
Object-Oriented Paradigm and UML28 Object Name Format object-name—simple name class-name—a name (simple or composite) stateList—list of strings; if suppressed, the square brackets are omitted The object-name and class-name may both be suppressed, but not simultaneously. object-name : class-name [ stateList ]
29
Object-Oriented Paradigm and UML29 Object Attribute Format attribute-name—simple name value—any string Any attribute and its current value may be suppressed together. attribute-name = value
30
Object-Oriented Paradigm and UML30 Examples of Object Symbols
31
Object-Oriented Paradigm and UML31 Object Diagram Uses Show the state of one or more objects at a moment during execution Dynamic models as opposed to class diagrams, which are static models (A static model represents aspects of a program that do not change during execution.) (A dynamic model represents aspects of a program that change during execution.)
32
Object-Oriented Paradigm and UML32 UML Diagram Tree Diagram Structure Diagram Class Diagram Component Diagram Composite Structure Diagram Deployment Diagram Object Diagram Package Diagram Behavior Diagram Interaction Diagram Sequence Diagram Communication Diagram Interaction Overview Diagram Timing Diagram Activity Diagram Use Case Diagram State Machine Diagram
33
Object-Oriented Paradigm and UML33 Procedural vs. Object-Oriented Thinking
34
Object-Oriented Paradigm and UML34 Stack of int ADT Carrier set: set of all stacks of ints –Empty stack –#0, #1, #2, … –#00, #01, #10, … –… Operations: push(), pop(), top(), isEmpty(), isFull(), …
35
Object-Oriented Paradigm and UML35 Procedural Approach Determine a way to represent the elements of the carrier set (a data structure) Determine how to implement the operations (procedures) Implement the data structure and procedures in code
36
Object-Oriented Paradigm and UML36 C stackOfInt Implementation stackOfInt.h stackOfInt.c main.c
37
Object-Oriented Paradigm and UML37 Object-Oriented Approach Encapsulate the carrier set and the operations in a class Determine how to implement the carrier set and operations Implement the class in code
38
Object-Oriented Paradigm and UML38 Class Design
39
Object-Oriented Paradigm and UML39 C++ IntStack Implementation IntStack.h IntStack.cpp main.c
40
Object-Oriented Paradigm and UML40 Example: Ph Monitor pH sensors in a vat are monitored A control chart is generated
41
Object-Oriented Paradigm and UML41 Procedural Approach Make a context diagram Make data flow diagrams Make ERDs Make a structure chart Implement the code
42
Object-Oriented Paradigm and UML42 pH Monitor Context Diagram
43
Object-Oriented Paradigm and UML43 pH Monitor Data Flow Diagram
44
Object-Oriented Paradigm and UML44 pH Monitor Structure Chart
45
Object-Oriented Paradigm and UML45 How to describe Requirement Result on OO? Use UML diagram Sometime you can use Use Case diagram as the first diagram. Move into another diagram as needed.
46
Object-Oriented Paradigm and UML46 Use Case Diagram Change Chart Display Chart Collect Sample
47
Object-Oriented Paradigm and UML47 pH Monitor Class Diagram
48
Object-Oriented Paradigm and UML48 Thank you
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.