1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd
Introduction: “Programing is fun, but developing quality software is HARD” In between the ‘nice’ ideas, the requirements or VISION, and a working software product, there is much more than programming. 2
This Course: Analysis and design, defining HOW to solve the problem, WHAT to program, CAPTURING the design (UML) in ways that are easy to COMMUNICATE, to review, to implement, and to evolve is what lies at the core of this course. 3
4 Questions: Why O-O Approach? What are the best practices in System Development Methodologies?
5 Objectives: Paradigm Agents and Communities Messages and Methods Responsibilities Classes and Instances Class hierarchy and Inheritance
6 Paradigm: “Paradigm” means example or model A paradigm sentence will help you remember how to conjugate a verb in a foreign language. Model helps one to understand how the world operates – Newtonian model of physics explains why apples fall to the ground
7 Applied to MIS/CS: A paradigm explains how the elements that go into making a computer program are organized and how they interact with one another: – We focus on the object-oriented worldview Let’s consider the following real-world situation and then see if we can model it with computer techniques, especially object oriented techniques:
8 Sending flowers: I wish to send flowers to a friend, Sally, living in a faraway city: – Because of the distance, I cannot carry them to Sally myself! – I go to Flora, the local florist, tell her the variety and quantity I wish to send, as well as Sally’s address – I know the flowers will be delivered!!
9 Agents and Communities: How did I solve my problem? – I found an appropriate agent (Flora) and pass a message with my request – Its Flora’s responsibility to satisfy my request – Flora, apply some method – algorithms or set of operations- to execute the request – I don’t know the particulars of this method, and is hidden from me
10 Flora’s Method/Messages: Flora send a message (slightly different than mine): – To another florist in my friend’s city – This florist send messages to: Flower wholesaler to obtain the flowers – Send a message to flower growers – Who has teams of gardeners Subordinate to make the floral arrangement To a delivery person to deliver the flowers
11 Summary: An object oriented program is structured as a community of interacting agents, called objects Each object has a role to play: they provide a service, or perform an action, that is used by the members of the community The action is activated by the transmission of a message to an agent or object responsible for the action.
12 Information hiding: This has to do with message passing: – The client sending the request need not know the actual means by which the request will be honored – This leads to encapsulation and objects become autonomous units: high level of cohesion. – This principle support the development of reusable components
13 Responsibilities: The behavior of the object is described in terms of responsibilities or protocol My request for action indicates only the desired outcome: flowers to my friend Flora is free to pursue any technique that will achieve the desired result: I cannot interfere! Independence between objects. A critical factor in solving complex problems: Low coupling
14 Classes and Instances: If I go to another flower shop, and meet the florist, say Rihanna, I have a good idea how she will respond to my request. After all, she is also a florist! It fits my assumptions in general about florists. This category (or type) of florists will follow a general pattern, of which Flora and Rihanna are instances: Flora and Rihanna represent the category or class of florist
15 Summary: All objects are instances of a class. The method invoked by an object in response to a message is determined by the class of the receiver. All objects of a given class use the same method in response to similar messages.
18 Class Hierarchies - Inheritance: Flora is a Florist As a florist, she will like any other shop, asked for money for the transaction, like grocers, stationers and other shopkeepers: a florist “is a” shopkeeper. One way to think about how I organized my knowledge of Flora is in terms of a hierarchy of categories.
19 Inheritance: Flora is a florist, and a florist is a specialized Shopkeeper. Shopkeeper “is again a” Human!! The principle that knowledge of a more GENERAL category is also applicable to a more SPECIFIC category is called inheritance Florist will inherit attributes of the class shopkeeper
20 Summary: Classes can be organized into a hierarchical inheritance structure, much like a tree. A child class or subclass will inherit attributes from a parent class higher in the tree. An abstract class is a class (such as Human) for which there are no direct instances; it is used to create subclasses. See next slide
21 Class Hierarchy: Human Shopkeeper Artist Dentist Florist Potter Flora Ntombi Kenneth
Course Goals and Outlines: Provide an Introduction to Object-Oriented Analysis and Design – Concepts – Terminology – Techniques Expose you to the UML Language Show how to apply basic OOAD techniques to a software engineering process. 22
This course will NOT: Make you an expert in OOAD Provide instruction on all aspects of UML Provide a software engineering process Turn you into a system architect Address O-O programming 23
Vision… Ours is a world where people don’t know what they want and are willing to go through hell to get it…. Don Marquis 24
Prescribed book: Introduction to Systems Analysis and Design – An Agile, Iterative Approach – 6 th Edition Satzinger, Jackson, Burd 25