1 cmis301 o-o thinking understanding o-o programming by t budd

25
1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

Upload: dustin-heath

Post on 17-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

1

CMIS301O-O Thinking

Understanding O-O Programming by

T Budd

Page 2: 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

Page 3: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 4: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

4

Questions:

Why O-O Approach? What are the best practices in System

Development Methodologies?

Page 5: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

5

Objectives:

Paradigm Agents and Communities Messages and Methods Responsibilities Classes and Instances Class hierarchy and Inheritance

Page 6: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 7: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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:

Page 8: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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!!

Page 9: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 10: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 11: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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.

Page 12: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 13: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 14: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 15: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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.

Page 16: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd
Page 17: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd
Page 18: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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.

Page 19: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 20: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 21: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

21

Class Hierarchy:

Human

Shopkeeper Artist Dentist

Florist Potter

Flora Ntombi Kenneth

Page 22: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 23: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 24: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

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

Page 25: 1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd

Prescribed book:

Introduction to Systems Analysis and Design– An Agile, Iterative Approach– 6th Edition

Satzinger, Jackson, Burd

25