Module 1 Introduction to OOAD ObjectOriented Analysis and

  • Slides: 49
Download presentation
Module 1: Introduction to OOAD (Object-Oriented Analysis and Design) Lawrence Chung CS 6359. OT

Module 1: Introduction to OOAD (Object-Oriented Analysis and Design) Lawrence Chung CS 6359. OT 1: Module 1 1

References l l l Object-Oriented Modeling and Design, Rumbaugh, et. al, Prentice Hall The

References l l l Object-Oriented Modeling and Design, Rumbaugh, et. al, Prentice Hall The Unified Modeling Language User Guide, Booch, et. al. Design Patterns; Elements of Reusable Object-oriented Software; Gamma, et. al. Appying UML and Patterns, Craig Larman Visual Modeling with Rational Rose and UML, Terry Quatrani 1998 Object-Oriented Methods: A Foundation, James Martin, et. al, 1995 Lawrence Chung CS 6359. OT 1: Module 1 2

Objectives l Why OO? l What is OOAD? l How to do OOAD? Lawrence

Objectives l Why OO? l What is OOAD? l How to do OOAD? Lawrence Chung CS 6359. OT 1: Module 1 3

Why Object-Oriented? “The "software crises" came about when people realized the major problems in

Why Object-Oriented? “The "software crises" came about when people realized the major problems in software development were not algorithmic, but were caused by communication difficulties and the management of complexity” [Budd] l The Whorfian Hypothesis: The language in which an idea is thought or expressed colors or directs in a very emphatic manner the nature of the thought What kind of language can alleviate difficulties with communication & complexity well? Lawrence Chung CS 6359. OT 1: Module 1 4

Why Object-Oriented? – Consider Human Growth & Concept Formation l l l Communication &

Why Object-Oriented? – Consider Human Growth & Concept Formation l l l Communication & complexity about the problem and the solution, all expressed in terms of concepts in a language! But then, What is CONCEPT? [Martin & Odell] Consider Human Growth & Concept Formation stage concepts infant the world is a buzzing confusion very young age "blue" "sky“ (individual concepts) "blue sky“ (more complex concept) hypothesis: humans possess an innate capacity for perception getting older -> increased meaning, precision, subtlety, . . . the sky is blue only on cloudless days the sky is not really blue it only looks blue from our planet Earth because of atmospheric effects elaborate conceptual constructs Concept formation: from chaos to order! Lawrence Chung CS 6359. OT 1: Module 1 5

Why Object-Oriented? - concepts and objects So, concepts are needed to bring order into

Why Object-Oriented? - concepts and objects So, concepts are needed to bring order into the problem and the solution But, What is CONCEPT? [Martin & Odell] [Novak, 1984, Cambridge University Press] Study of a first grade class When given a list of concepts (water, salt water, Oceans, Penguins, . . . ), Harry constructed a concept diagram through which he understands his world and A "concept" is anmeaning idea or notion that we apply to the things, or objects, in our awareness communicates Lawrence Chung CS 6359. OT 1: Module 1 6

Why Object-Oriented? … for Conceptual Modeling Reasons What kind of language is used to

Why Object-Oriented? … for Conceptual Modeling Reasons What kind of language is used to create this concept diagram, or Harry’s mental image? What are the building blocks of Harry’s perception of this piece of reality, represented in his mind/brain? Object-Orientation (OO) = Being “conceptual” OO analysis & design = “Conceptual” analysis & design But for what? for Modeling! Analysis for Model of the problem design for Model of the solution “conceptual” analysis for “conceptual” model of the problem “conceptual” design for “conceptual” model of the solution Lawrence Chung CS 6359. OT 1: Module 1 7

Why Object-Oriented -> What is a model? l A model is a simplification of

Why Object-Oriented -> What is a model? l A model is a simplification of reality. E. g. , a miniature bridge for a real bridge to be built l Well. . . sort of…. but not quite l A model is our simplification of our perception of reality (that is, if it exists, otherwise it could be a mere illusion). Your perception, my perception, his, hers, …, => communication is not about reality but about your/my/his/her perception of reality => validation and verification hard but needed l A model is an abstraction (omitting tremendous amount of details) of something for the purpose of understanding, be it the problem or a solution. A model (like Harry’s) is expressed in terms of concepts in a language! Lawrence Chung CS 6359. OT 1: Module 1 8

What is Object-Orientation - Abstraction and Encapsulation Abstraction Focus on the essential Focus on

What is Object-Orientation - Abstraction and Encapsulation Abstraction Focus on the essential Focus on what an object “is and does” Omits tremendous amount of details Encapsulation a. k. a. information hiding Objects encapsulate: state as a collection of instance variables behavior as a collection of methods invoked by messages Lawrence Chung CS 6359. OT 1: Module 1 9

What is Object-Orientation - Example of Abstraction and Encapsulation Class Car Attributes q Model

What is Object-Orientation - Example of Abstraction and Encapsulation Class Car Attributes q Model q Location Operations q Start q Accelerate Lawrence Chung CS 6359. OT 1: Module 1 10

What is Object-Orientation? - Object l What is OBJECT? A "concept" is an idea

What is Object-Orientation? - Object l What is OBJECT? A "concept" is an idea or notion that we apply to the things, or objects, in our awareness An "object" is anything to which a concept applies. l Thing drawn from the problem domain or solution space. l l E. g. , a living person in the problem domain, a software component in the solution space. A structure that - has identity (i. e. , discrete and distinguishable), and - bundles together attributes (the data part, or state) and behavior (the function/code part). l It is an instance of a collective concept, i. e. , a class. l Lawrence Chung CS 6359. OT 1: Module 1 11

What is Object-Orientation? - Class l What is CLASS? l l l Classification l

What is Object-Orientation? - Class l What is CLASS? l l l Classification l l An object created by a class. Instantiation. l l Grouping of common objects into a class Instance. l l a collection of objects that share common properties, attributes, behavior and semantics, in general. A collection of objects with the same data structure (attributes, state variables) and behavior (function/code/operations) in the solution space. A blueprint or definition of objects. A factory for instantiating objects. The description of a collection of related components. The act of creating an instance. Cf. Containment. l Objects that contain other objects as components. Lawrence Chung CS 6359. OT 1: Module 1 12

What is Object-Orientation - Subclass vs. Superclass • Specialization The act of defining one

What is Object-Orientation - Subclass vs. Superclass • Specialization The act of defining one class as a refinement of another. • Subclass A class defined in terms of a specialization of a superclass using inheritance. • Superclass A class serving as a base for inheritance in a class hierarchy • Inheritance Automatic duplication of superclass attribute and behavior definitions in subclass. What is generalization? What is over-generalization? Lawrence Chung CS 6359. OT 1: Module 1 13

What is Object-Orientation? -State l What is STATE? "State" is a collection of association

What is Object-Orientation? -State l What is STATE? "State" is a collection of association an object has with other objects and object types. l What is STATE CHANGE? A "state change" is the transition of an object from one state to another. l What is EVENT? An "event" is a noteworthy change in state. Lawrence Chung CS 6359. OT 1: Module 1 14

What is Object-Orientation – More about Message An object (sender) sends a request (message)

What is Object-Orientation – More about Message An object (sender) sends a request (message) to another object (receiver) to invoke a method of the receiver object’s. A message is similar to a function call, but different a message must somehow reference the intended recipient object the recipient object only responds to the protocol, i. e. , a predetermined set of messages defined by its class. Data message Fn Sender object Lawrence Chung Fn Receiver object CS 6359. OT 1: Module 1 15

What is Object-Orientation? - Object-Oriented Application • Collection of discrete interacting objects • Objects

What is Object-Orientation? - Object-Oriented Application • Collection of discrete interacting objects • Objects have behavior and state • Inter-object communication through message passing Data Fn Fn Data Fn Lawrence Chung CS 6359. OT 1: Module 1 16

What is OOAD? l Analysis l Design — understanding and defining software — understanding,

What is OOAD? l Analysis l Design — understanding and defining software — understanding, finding and describing concepts in the problem domain. solution/objects that represent the analysis concepts and will eventually be implemented in code. l OOAD — Analysis is object-oriented and design is objectoriented. A software development approach that emphasizes a logical solution based on objects. Lawrence Chung CS 6359. OT 1: Module 1 17

How to Do OOAD – Where to Use OO? Software Lifecycle Review Systems Engineering

How to Do OOAD – Where to Use OO? Software Lifecycle Review Systems Engineering Project Planning Architectural Design Detailed Design Quality Assurance Requirements Analysis Maintenance Implementation Release Where to use OO in software lifecycle? Where in this course? Lawrence Chung CS 6359. OT 1: Module 1 18

How to Do OOAD – OMT as Object-Oriented Methodology OMT (Object Modeling Technique) by

How to Do OOAD – OMT as Object-Oriented Methodology OMT (Object Modeling Technique) by James Rumbaugh Object Model: describes the static structure of the objects in the system and their relationships -> Object Diagrams. Dynamic Model: describes the interactions among objects in the system -> State Diagrams. Functional Model: describes the data transformation of the system -> Data. Flow Diagrams. Lawrence Chung CS 6359. OT 1: Module 1 19

How to Do OOAD – OMT as Object-Oriented Methodology OMT (Object Modeling Technique) by

How to Do OOAD – OMT as Object-Oriented Methodology OMT (Object Modeling Technique) by James Rumbaugh Analysis: Model the real world showing its important properties; Concise model of what the system will do System Design: Organize into subsystems based on analysis structure and propose architecture Object Design: Based on analysis model but with implementation details; Focus on data structures and algorithms to implement each class; Computer and domain objects Implementation: Translate the object classes and relationships into a programming language Lawrence Chung CS 6359. OT 1: Module 1 20

How to Do OOAD - Historical Perspective OO Technology Process Perspective OO Prog. Languages

How to Do OOAD - Historical Perspective OO Technology Process Perspective OO Prog. Languages just program! (Smalltalk, C++) OO Design design then program (Booch) Analyze (use case) first, OO Analysis (Rumbaugh, Jacobson) then design, T Lawrence Chung CS 6359. OT 1: Module 1 then program 21

How to Do OOAD - OO Development Processes Some Popular OOAD Processes l Fusion

How to Do OOAD - OO Development Processes Some Popular OOAD Processes l Fusion l l Recommended Process and Models l l l Hewlett Packard Object. Space best practices Larman’s experiences The Rational Unified Process (RUP) l Rational; Booch, Jacobson, and Rumbaugh Lawrence Chung CS 6359. OT 1: Module 1 22

How to Do OOAD – One Good Way: Use (OO) Design Patterns Reusable solutions

How to Do OOAD – One Good Way: Use (OO) Design Patterns Reusable solutions to typical problems. “Each design pattern systematically names, explains, and evaluates an important and recurring design in object-oriented systems. ” [Gamma] l Name — identifies a particular pattern, creating a vocabulary. l Problem l Solution l Consequences — identifies context when pattern should be applied. — an abstract description of a design problem along with a template object design that solves the problem. Lawrence Chung — results and trade-offs of applying the pattern. CS 6359. OT 1: Module 1 23

Introduction to OOAD - Summary Why Software Crisis due to Communication and Complexity l

Introduction to OOAD - Summary Why Software Crisis due to Communication and Complexity l Languages, Concepts, Models l OO for Conceptual Modeling l Historical Perspective of Modeling Paradigms l What l Fundamental OO Concepts How l Design patterns & OO development processes Lawrence Chung CS 6359. OT 1: Module 1 24

Introduction to OOAD - Points to Ponder 1. 2. 3. 4. 5. 6. 7.

Introduction to OOAD - Points to Ponder 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. How do you think your mental image is represented? What kinds of languages are used for what purpose in our daily life? What are the differences among a concept, a model and a language? What are the differences between a language and a methodology? Can we use C# for analysis? If C++ is a language, does it model anything? If so, what? What does a concept in C++ refer to (i. e. , semantics)? What does a concept in a (OO) design refer to? What does a concept in an (OO requirements) analysis refer to? Is the current OOAD for Functional Analysis and Design, or Non. Functional Analysis and Design? What is the relationship between OO (Object-Orientation) and GO (Goal-Orientation), between OO and AO (Agent-Orientation), and between GO and AO? Can you prove you and I communicate with each other perfectly? Lawrence Chung CS 6359. OT 1: Module 1 25

Module 1: Introduction to OOAD - Appendix (Object-Oriented Analysis and Design) Lawrence Chung CS

Module 1: Introduction to OOAD - Appendix (Object-Oriented Analysis and Design) Lawrence Chung CS 6359. OT 1: Module 1 26

Why Object-Oriented – Why Do We Model? To understand why a software system is

Why Object-Oriented – Why Do We Model? To understand why a software system is needed, what it should do, and how it should do it. l To communicate our understanding of why, what and how. l To detect commonalities and differences in your perception, my perception, his perception and her perception of reality. l To detect misunderstandings and miscommunications. l For just about everything! Lawrence Chung CS 6359. OT 1: Module 1 27

Why Object-Oriented - Importance of Conceptual Modeling Once More No reason to build a

Why Object-Oriented - Importance of Conceptual Modeling Once More No reason to build a system for which there is no reason to -> understand the reason – part of the problem, hence analysis l No way to build a system for which there is no understanding of its structure, parts and relationships -> understand the solution, hence design l We build models of complex systems because we cannot understand such a system in its entirety… l Without conceptual models of complex systems, both problems and solutions, we cannot understand such a system in its entirety. Object-Orientation is for conceptual modeling! Cf. Representing people in a stack is not conceptual in the problem space. Lawrence Chung CS 6359. OT 1: Module 1 28

Why Object-Oriented - Who’s Behind Object-Orientation Knowledge Representation (in A. I. ) Databases Psychological

Why Object-Oriented - Who’s Behind Object-Orientation Knowledge Representation (in A. I. ) Databases Psychological Validity Relational. DB Emphasis in Persistent Data ERD Philosophical Validity Computational Validity Network DB Hierarchical DB CM SDM ADT OODB Programming Languages ERD: Entity Relationship Diagram Emphasis in Efficiency SDM: Semantic Data Model Simula, Small. Talk, C++, Protel, Java ADT: Abstract Data Type CM: Conceptual Model What role does Software Engineering play? Lawrence Chung CS 6359. OT 1: Module 1 29

Why Object-Oriented? - Communication & Complexity about Problem and Solution So, let us try

Why Object-Oriented? - Communication & Complexity about Problem and Solution So, let us try to Communicate well and Conquer the complexity well But about what? …about what is really critical… Experience shows: l l DEFINING THE "PROBLEM" (analysis) is THE "PROBLEM“ ARCHITECTURAL DESIGN (the highest level of solution) can, literally, make it or break it (high-level design) So, let us try to Communicate well and Conquer the complexity well about analysis and design! Common wisdom says: "Divide and Conquer" -> decompose the problem & the solution into manageable parts This can help (methodologically) with adaptability, parallel development and deployment of the system, etc. But still, what kind of language can alleviate difficulties with communication & complexity well about the analysis and the design, and suited well to the divide and conquer methodology? Lawrence Chung CS 6359. OT 1: Module 1 30

Why Object-Oriented - Who’s Behind Object-Orientation? Lawrence Chung CS 6359. OT 1: Module 1

Why Object-Oriented - Who’s Behind Object-Orientation? Lawrence Chung CS 6359. OT 1: Module 1 31

Why Object-Oriented – Is OO A New Paradigm? Paradigm: “way of looking at things”

Why Object-Oriented – Is OO A New Paradigm? Paradigm: “way of looking at things” l Yes! OO does present a new way. l Programming Paradigms Imperative Procedures & Algorithms Function-oriented Mathematical functions Logic-oriented Goals, predicate logic Object-oriented Classes & Objects Rule-oriented Expert systems Constraint-oriented Invariant relations Lawrence Chung CS 6359. OT 1: Module 1 32

Why Object-Oriented – A New Paradigm with Evolving Object Orientation l OOP: Object-Oriented Programming

Why Object-Oriented – A New Paradigm with Evolving Object Orientation l OOP: Object-Oriented Programming l l OOD: Object-Oriented Design l l Simula (1967), Smalltalk (70’s), C++ (mid 80’s), Eiffel, Ada 95, Turing, … Taxis (1976), Adaplex, …, Grady Booch (1980) OOA: Object-Oriented Requirements l RML (1981), James Rumbaugh (late 80’s) OO-Databases (OODBs): 1980 -90’s l OLE/DCOM, Visual. Basic, CORBA, Java, UML: mid l 90’s l . Net, C#, (eb/voice…/-)XML, J 2 EE: into 2000+ Lawrence Chung CS 6359. OT 1: Module 1 33

Why Object-Oriented – Why Shift in Modeling Paradigm l From Functional l l Functions

Why Object-Oriented – Why Shift in Modeling Paradigm l From Functional l l Functions as building blocks (fn: Input -> Output) Algorithmic perspective E. g. , Lisp To Object-Oriented l l Objects as building blocks. Conceptual perspective from the vocabulary of the problem space for analysis from the vocabulary of the solution space for design Lawrence Chung CS 6359. OT 1: Module 1 34

Why Object-Oriented – Functional Object-Oriented Decompose system functionality Identify concepts, in terms of both

Why Object-Oriented – Functional Object-Oriented Decompose system functionality Identify concepts, in terms of both function and data together Fn Fn Data e. g. , Structure Chart Lawrence Chung CS 6359. OT 1: Module 1 35

Why Object-Oriented - Why Away From Functionally Structured Solution Product quality is static or

Why Object-Oriented - Why Away From Functionally Structured Solution Product quality is static or worsening, & increased testing l Increasing number of manpower - programmers l Long lead time, 2+ years for new commercial applications development l Significant amount of maintenance efforts & delay in adaptation to new hardware l Lawrence Chung CS 6359. OT 1: Module 1 36

Why Object-Oriented - Programming Language Perspective First Generation (1954 -1958) l Fortran I l

Why Object-Oriented - Programming Language Perspective First Generation (1954 -1958) l Fortran I l Second Generation (1959 -1961) l Fortran II, Algol, Cobol l Third Generation (1962 -1970) l PL/I, Pascal l Object-Oriented Languages l Smalltalk, C++, Java l Lawrence Chung CS 6359. OT 1: Module 1 37

1 st Generation 2 nd Gen Fortran II, Algol, Cobol Lawrence Chung CS 6359.

1 st Generation 2 nd Gen Fortran II, Algol, Cobol Lawrence Chung CS 6359. OT 1: Module 1 38

3 rd Generation Object Oriented Data Fn Fn Data Fn PL/I, Pascal Lawrence Chung

3 rd Generation Object Oriented Data Fn Fn Data Fn PL/I, Pascal Lawrence Chung Allocation of functionality to objects Shift from monolithic to decentralized control Object-Oriented Programming Languages (OOPL) CS 6359. OT 1: Module 1 39

What is Object-Orientation - Abstract Class vs. Concrete Class l Abstract Class. l l

What is Object-Orientation - Abstract Class vs. Concrete Class l Abstract Class. l l l An incomplete superclass that defines common parts. Not instantiated. Concrete class. l l l Is a complete class. Describes a concept completely. Is intended to be instantiated. Lawrence Chung CS 6359. OT 1: Module 1 40

What is Object-Orientation – Operation vs. Message vs. Method l What is OPERATION? An

What is Object-Orientation – Operation vs. Message vs. Method l What is OPERATION? An "operation" is a process that can be requested as a unit. It is the mechanism for state change (i. e. , event). - Behavior across different kinds of objects l What is MESSAGE? - specify what behavior receiver objects need to perform l l l - details of how to perform are left up to the receiver - state information is accessed via messages What is METHOD? - specify how operations are to be carried out (hence implements a message) l l - must have access to data - can manipulate data directly - Specific implementation of an operation by a certain class Lawrence Chung CS 6359. OT 1: Module 1 41

What is Object-Orientation - Interfaces • All data should be hidden within a class.

What is Object-Orientation - Interfaces • All data should be hidden within a class. • make all data attributes private • provide public methods (accessor methods) to get and set the data values • e. g. Grade information is usually confidential, hence it should be kept private to the student. Access to the grade information should be done through interfaces, such as set. Grade() and get. Grade() Data set. Grade() Fn get. Grade() Lawrence Chung CS 6359. OT 1: Module 1 42

What is Object-Orientation – How It All Fits Together? l l l An application

What is Object-Orientation – How It All Fits Together? l l l An application is a set of objects that interact by sending messages An object’s functionality is invoked by sending a message An object’s functionality is implemented by methods The data needed to support an object’s functionality is stored locally within an object All application code must be associated with some object Lawrence Chung CS 6359. OT 1: Module 1 43

What is Object-Orientation - Polymorphism The same operation may behave differently in different classes.

What is Object-Orientation - Polymorphism The same operation may behave differently in different classes. Objects of different classes respond to the same message differently. In-state Student pay. Tuition () Out-of-State Student Lawrence Chung CS 6359. OT 1: Module 1 44

OOPL: Simula l l l Developed for discrete event simulation (1967) Simulation modeling is

OOPL: Simula l l l Developed for discrete event simulation (1967) Simulation modeling is a hard problem for conventional languages Simulated objects must interact and change state in many different and often unpredictable ways Simulation can solve problems that are too complex for mathematical equations Simulation objects are usually easy to identify and communicate via message passing Lawrence Chung CS 6359. OT 1: Module 1 45

OOPL: Smalltalk From Xerox PARC, by Alan Kay and Adele Goldberg l Towards a

OOPL: Smalltalk From Xerox PARC, by Alan Kay and Adele Goldberg l Towards a small language for anyone to use on a PC l Influenced by Simula: objects and classes l Influenced The WIMP interface l (Windows, Icons, Menu, Pointing device) l Influenced Apple’s design of Lisa and Macintosh Lawrence Chung CS 6359. OT 1: Module 1 46

OOPL: C++ From AT&T Bell Labs – invented by Bjorne Stroustrup http: //www. research.

OOPL: C++ From AT&T Bell Labs – invented by Bjorne Stroustrup http: //www. research. att. com/~bs/C++. html l Adds object-oriented features to C l Classes in C++ correspond to types in C l Lawrence Chung CS 6359. OT 1: Module 1 47

OOPL: Ada 95 DOD support for embedded systems l Enforces Abstract Data Types (ADTs)

OOPL: Ada 95 DOD support for embedded systems l Enforces Abstract Data Types (ADTs) l l l Data, operations on data, constraints on operations E. g. , formal specification languages - Larch, Z, VDM Support for multitasking and exceptions l Large and complex l Lawrence Chung CS 6359. OT 1: Module 1 48

OOPL: Java l l l Like C++ in syntax Like Smalltalk in Structure and

OOPL: Java l l l Like C++ in syntax Like Smalltalk in Structure and design Without the drawbacks to C++ and Smalltalk l Frees the programmer from having to manage memory (accidental complexity) l Small footprint (memory requirement) No pointers, pointer arithmetic, structs, typedefs, preprocessor directives (#define), malloc and free With extensive type checking, true arrays with array bounds checking, null pointer checking, automatic garbage collection Lawrence Chung CS 6359. OT 1: Module 1 49