Module 1: Introduction to OOAD PDF
Document Details
Uploaded by RemarkablePurple
Tags
Summary
This document provides an introduction to object-oriented analysis and design (OOAD). It explores fundamental concepts, such as communication difficulties, object-oriented design, and software crisis. The document also includes case studies like Tesla cars.
Full Transcript
Module 1: Introduction to OOAD (Object-Oriented Click to add Text Analysis and Design) 1 Why Object-Oriented? 2 Why Object-Oriented? “The "software crises" came about when people realized the major problems in softwa...
Module 1: Introduction to OOAD (Object-Oriented Click to add Text Analysis and Design) 1 Why Object-Oriented? 2 Why Object-Oriented? “The "software crises" came about when people realized the major problems in software development were … caused by communication difficulties and the management of complexity” [Budd] The Whorfian Hypothesis: Human beings … are very much at the mercy of the particular language which has become the medium of expression for their society … the 'real world' is … built upon the language habits … We cut nature up, organize it into concepts, and ascribe significances as we do, largely because we are parties to an agreement to organize it in this way … and is codified in the patterns of our language. ❖ What kind of language can alleviate difficulties with 3 communication & complexity hopefully well? Why Object-Oriented? – Consider Human Growth & Concept Formation ⚫ 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! 4 Why Object-Oriented? - concepts and objects So, concepts are needed to bring order … into 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 communicates meaning Does Harry understand the concepts? Do you understand what Harry understands? Agree or Diagree? 5 Why Object-Oriented? … for Conceptual … Modeling Reasons What kind of language can be used to create this concept diagram, or Harry’s mental image? Water have Fresh water Rivers Oceans have have live in have Salt water have Crocodiles Fish Penguins 6 Why Object-Oriented -> What is a model and why? ⚫ A model is a simplification of reality. E.g., a miniature bridge for a real bridge to be built ⚫ Well...sort of….but not quite ⚫ A model is our simplification of our perception of reality (that is, if it exists, otherwise it could be a mere illusion). communication is not about reality but about your/my/his/her perception of reality => validation and verification hard but needed ⚫ A model is an abstraction of something for the purpose of understanding, be it the problem or a solution. ⚫ To understand why a software system is needed, what it should do, and how it should do it. ⚫ To communicate our understanding of why, what and how. ⚫ To detect commonalities and differences in your perception, my perception, his perception and her perception of reality. ⚫ To detect misunderstandings and miscommunications. 7 What is Object-Orientation? - What is Object? ⚫ An "object" is anything to which a concept applies, in our awareness ⚫ Things drawn from the problem domain or solution space. ⚫ E.g., a living person in the problem domain, a software component in the solution space. ⚫ A structure that has identity and properties and behavior ⚫ It is an instance of a collective concept, i.e., a class. 8 What is Object-Orientation - Abstraction and Encapsulation Abstraction Focus on the essential Omits tremendous amount of details …Focus on what an object “is and does” Encapsulation a.k.a. information hiding Objects encapsulate: property behavior as a collection of methods invoked by messages …state as a collection of instance variables 9 What is Object-Orientation - Another Example of Abstraction and Encapsulation Class Car Attributes ❑ Model ❑ Location ❑ #Wheels = 4 Operations ❑ Start ❑ Accelerate 10 What is Object-Orientation? - Class Class Car Attributes ❑ Model ❑ Location ❑ #Wheels = 4 Operations ❑ Start ❑ Accelerate ⚫ What is CLASS? ⚫ 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. ⚫ Classification ⚫Grouping of common objects into a class ⚫ Instance. 11 ⚫ The act of creating an instance. 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. Person name SSN Student Employee std-id emp-id multiple inheritance? level age 12 What is Object-Orientation - Interfaces Information hiding - all data should be hidden within a class, at least in principle. make all data attributes private provide public methods to get and set the data values (cf. Java design patterns) 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 setGrade and getGrade Student setGrade std-id level payTuition grade setGrade() getGrade() getGrade 13 What is Object-Orientation? -State ⚫ What is STATE? "State" is a collection of association an object has with other objects and object types. ⚫ What is STATE CHANGE? A "state change" is the transition of an object from one state to another. ⚫ What is EVENT? An "event" is a noteworthy change in state 14 What is Object-Orientation - Polymorphism 15 What is OOAD? ⚫ Analysis — understanding, finding and describing concepts in the problem domain. ⚫ Design — understanding and defining software solution/objects that represent the analysis concepts and will eventually be implemented in code. ⚫ OOAD — Analysis is object-oriented and design is object- oriented. A software development approach that emphasizes a logical solution based on objects. Involves both a notation and a process 16 How to Do OOAD – Where to Use OO? Software Lifecycle Systems Engineering Quality Assurance Requirements Analysis Project Planning Maintenance Architectural Design Detailed Design Implementation Release 17 Artificial problem Accidental design 18 How to Do OOAD – OMT as Object-Oriented Methodology 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 -> DataFlow Diagrams. 19 Case Study : Tesla Cars Key concepts of object-oriented programming using Tesla electric vehicles as a case study: Classes. These can be imagined as something like templates, from which specific objects will be created later on. These are all Tesla electric vehicles, for which not only the attributes considered basic (engines, batteries, and other elements) are defined, but also methods for their retrieval (start, move, stop), as well as modification (software update). Objects. Instances of classes that represent real-world entities or concepts. For example, objects of the Tesla Electric Vehicles class may have attributes in the form of colour (graphite, blue, white, red) and model (Model S, Model 3, Model X, Model Y), as well as methods in the form of starting, accelerating, stopping, and also, if necessary, servicing (software update, autopilot feature purchase). Inheritance. This mechanism defines the process by which a new class is created based on an existing one, inheriting all its attributes and methods. For example, any Tesla model gets similar software (it is not rewritten multiple times to avoid duplicating code), but also a whole range of individual parameters specific to each model (display size in the cabin and seat finish). Polymorphism. The ability of an object to use methods defined in its class as well as in its superclasses. This allows objects of different classes to be treated as objects of the base class, significantly simplifying the code and making it as flexible as possible (the autopilot on all Tesla models works, by and large, the same way). Encapsulation. The hiding of an object's internal data and requiring access to them through the object's methods. This helps control the change in the object's state and protects it from incorrect use. When considering Tesla electric vehicles, this would mean starting each of them only in the way defined by the manufacturer. 20 A Unified Language + A Good Process + A Good Goal, perhaps 21