Full Transcript

SWE202 SOFTWARE CONSTRUCTION WEEK 2 Introduction to Object Oriented Analysis and Design Oluwaseun Priscilla Olawale (MSc.) Objectives Why OO? What is OOAD? How to do OOAD? 2 Why Object-Orie...

SWE202 SOFTWARE CONSTRUCTION WEEK 2 Introduction to Object Oriented Analysis and Design Oluwaseun Priscilla Olawale (MSc.) Objectives Why OO? What is OOAD? How to do OOAD? 2 Why Object-Oriented? Genesis 11:1-9 Acts 2:1-4 The Tower Of Babel Let's become famous by building a city with a tower that reaches up to heaven (verse four). Let's go down and confuse their speech right away, and make it so that they will not understand each other's speech. (verses five through seven). 3 Oluwaseun Olawale (MSc.) Why Object-Oriented? 4 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.  ❖  5 What kind of language can alleviate difficulties with 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! 6 Why Object-Oriented? - concepts and objects So, concepts are needed to bring order … into But, What is CONCEPT? 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 7 Does Harry understand the concepts? Do you understand what Harry understands? Agree or Diagree? Why Object-Oriented? … for Conceptual … Modelling Reasons What kind of language can be used to create this concept diagram, or Harry’s mental image? Water Fresh water have Rivers Oceans have have live in Salt water have Crocodiles Fish have Penguins 8 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. 9 ○ To detect misunderstandings and miscommunications. 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. ⚫ structure that has identity and properties and behavior ⚫ It is an instance of a collective concept, i.e., a class. 10 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 11 What is Object-Orientation - Another Example of Abstraction and Encapsulation Class Car Attributes ❑ Model ❑ Location ❑ #Wheels = 4 Operations ❑ Start ❑ Accelerate What is generalization? What is over-generalization?? Forall x [Car(x) -> …] 12 What is Object-Orientation? - Class Attributes ❑ Model ❑ #Wheels = 4 Operations ❑ Accelerate What is CLASS? ○ a collection of objects that share common properties, attributes, behavior and semantics, in general. What are all these??? ○ 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 Instantiation ○ The act of creating an instance. 13 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 level age multiple inheritance? 14 To be continued… 15

Use Quizgecko on...
Browser
Browser