object-oriented programming

47
Lesson 16 McManus COP1006 1

Upload: adena-cantrell

Post on 04-Jan-2016

34 views

Category:

Documents


1 download

DESCRIPTION

Object-Oriented Programming. Lesson 16. Overview. OOP Classes Objects Inheritance Functions GUI. Event-driven Object-Oriented Programming Events Interactivity. Basic Concepts. Procedural Looks at the actions or the data but not both at the same time. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Object-Oriented Programming

Lesson 16

McManusCOP1006 1

Page 2: Object-Oriented Programming

OOP◦Classes◦Objects◦Inheritance◦Functions

GUI

Event-driven Object-Oriented Programming◦Events◦Interactivity

McManusCOP1006 2

Page 3: Object-Oriented Programming

Procedural◦Looks at the

actions or the data but not both at the same time.

◦Associated with menu-driven systems

Object-Oriented◦Looks at the data

parts and the actions associated with those data parts as one unit.

◦Associated with GUI systems

McManusCOP1006 3

Page 4: Object-Oriented Programming

A programming methodology in which the programmer can define not only data types, but also procedures that are automatically associated with them.

McManusCOP1006 4

Page 5: Object-Oriented Programming

User-defined types created by programmers

Contains data as well as the set of methods which manipulate that data.◦ Data components of a class are called instance

variables.◦ Nouns are used to create initial set of classes.◦ Verbs determine what methods to associate

with each class.◦ Can only contain code--no GUI elements.

Ex. Books

McManusCOP1006 5

Page 6: Object-Oriented Programming

An individual (member) instantiation of a class

Ex.◦ Harry Potter and the Sorcerer’s Stone

by J. K. Rowling◦ It

by Stephen King More about Classes & Objects later

McManusCOP1006 6

Page 7: Object-Oriented Programming

Graphical objects (drawing tools) Mathematical objects

◦ Vectors, matrices Input-output devices

◦ The procedure to draw a line is different to different outputs

Simulations Reusable software components

McManusCOP1006 7

Page 8: Object-Oriented Programming

Enables implementation decisions to be made in stages: ◦ top level - focus on how to use a data object and

on what operators (procedures and functions) are needed.

◦ lower level - concentrate on implementation details.

McManusCOP1006 8

Page 9: Object-Oriented Programming

Programmers ◦ create new classes◦ reuse existing classes

Software is created by new classes with existing, well-defined, carefully tested, well-documented, widely available components.

Promotes Rapid Applications Development (RAD)

McManusCOP1006 9

Page 10: Object-Oriented Programming

Being able to describe an object’s behaviors without being concerned with the implementation details of those behaviors.

Classes can be replaced without affecting the remainder of the code.

McManusCOP1006 10

Page 11: Object-Oriented Programming

Library Checkout System◦ We would look at:

Menu-driven program Data input Checking out a book Checking in a book Printouts of all outstanding books Printouts of all books Add, delete, and update book info

McManusCOP1006 11

Page 12: Object-Oriented Programming

Library Checkout System◦ We would look at:

Books Recognize Book ID Recognize the Book’s author Check out Check in Location of book List all books Add, delete, and change data on a book

McManusCOP1006 12

Page 13: Object-Oriented Programming

13

Looks Yummy!

I’m sure gladI don’t have to eat

this stuff!

Page 14: Object-Oriented Programming

14

Customer

Waiter (object)

Data: name: Joetables: 1,2tickets: 2

Methods: takeOrder putOrderonTurnstile pickup Order serverOrder

Turnstile (object)

Data: tickets: 1

Methods: isTicketReady add Ticket remove Ticket

Cook (object)

Data: name: Arnold specialties: HamandEggs Pancakes FrenchToast

Private Methods:makeHamandEggsmakePancakesmakeFrenchToast

Public Methods: takeTicketFromTurnstile putOrderOnCounter

Counter (object)

Data:ordersAvailable

Methods:isOrderReadyaddOrderremoveOrder

Messages invoke methods &methods send messages.

Page 15: Object-Oriented Programming

15

Menu

Breakfast Menu Dinner MenuLunch Menu

Child’s Menu Adult Menu

Senior MenuSt. Patrick’s

Day Menu

What characteristics should be defined at what level and what would be inherited by each object and to what level?

Page 16: Object-Oriented Programming

McManusCOP1006 16

Page 17: Object-Oriented Programming

Program design technique ◦ focuses on

the data objects needed by a program and the operations on those objects.

It specifies what data objects are needed for a problem without being concerned how the data objects will be represented.

McManusCOP1006 17

Page 18: Object-Oriented Programming

New data types can be defined based on previously defined objects◦ sharing code and behavior; and◦ involves classification of objects according to

shared properties

McManusCOP1006 18

Page 19: Object-Oriented Programming

McManusCOP1006 19

AnimaliaAnimals

ProtozoaOne-Celled Animals

Parazoa Metazoa

PoriferaSponges

MolluscaMolluscs

ChordataChordates

AnnelidaSegmented Worms

ArthropodaJoint-Footed Animals

UrochordataTunicates

ThaliaceaSalps

AscidiaceaSea Squirts

VertebrataVertebrates

CephalocordataLancelets

ReptiliaReptiles

AmphibiaAmphibians

AgnathaLampreys &

Hagfishes

AvesBirds

MammaliaMammals

TestudinataTortoises

SerpentesSnakes

LacertiliaLizards

ChamaeleonidaeChameleons

IguanidaeNew World Lizards

TubulidendataAardvarks

CetaceaWhales

PrimatesPrimates

ChiropteraBats

HominidaeTupaiidae

ShrewsLemuridae

Lemurs

CrustaceaLobsters

ArachnidaSpiders

InsectaInsects

ChilopodaCentipedes

IsopteraTermites

PsocopteraBooklice

HemipteraBugs

CorixidaeWater-Boatmen

PentatomidaeStink-Bugs

TingidaeLace-Bugs

Page 20: Object-Oriented Programming

a variable with the same type as the data object◦ Class - Singly-linked List◦ Object – A specific Singly-linked List

McManusCOP1006 20

Page 21: Object-Oriented Programming

Concealing the details of a low-level module’s implementation from a higher-level module.

Looks forward to future maintenance by building details into the design phase.

McManusCOP1006 21

Page 22: Object-Oriented Programming

The use of different procedures, each with the same name, which are associated with different object types.◦ Allows each object to recognize the properties

pertinent to itself and to ignore those that are not.

McManusCOP1006 22

Page 23: Object-Oriented Programming

Example:◦ Procedures named draw associated with types

Point Circle Square

◦ Calling draw for any particular object gets the right drawing procedure for that type.

McManusCOP1006 23

Page 24: Object-Oriented Programming

McManusCOP1006 24

Base Class

Generic recordset

Derived Classes

Dynaset-type recordset

Snapshot-type recordset

Table-type recordset

Uses the same name as the abstract data type recordset

Page 25: Object-Oriented Programming

A collection of like items or objects. Examples

◦ Books◦ Clients◦ Waiter◦ Cook

McManusCOP1006 25

Page 26: Object-Oriented Programming

An instance (member) of a class. Instances of Books

◦ Stephen King’s It◦ Mark Twain’s Tom Sawyer◦ J.K. Rowling’s Harry Potter and the Sorcerer’s

Stone◦ Tom Clancy’s Hunt for Red October

McManusCOP1006 26

Page 27: Object-Oriented Programming

Visual Basic’s Toolbox contains controls, each a class of objects.

Once selected, each instantiation is an object of a particular class of objects.

Used in GUI’s.

McManusCOP1006 27

Page 28: Object-Oriented Programming

Computer screen designed for easy interaction between the user and the computer.

Response to the demand by users for more user-friendliness in their interactivity with computers.

Takes up a HUGE amount of space. Languages that create GUI’s

◦ C++ and Visual Basic

McManusCOP1006 28

Page 29: Object-Oriented Programming

Each language has own set of events Examples of events

◦ Mousedown◦ Mouseup◦ Keydown◦ Keyup◦ Double click◦ Single click

McManusCOP1006 29

Page 30: Object-Oriented Programming

Use actions or events to trigger the execution of a set of instructions ◦ Sometimes called scripts or modules

The user dictates the order of program execution--not the programmer.

The program is instructed as to what actions to perform when events happen to those objects.

McManusCOP1006 30

Page 31: Object-Oriented Programming

Events are triggered by messages◦ When an event occurs, a message is generated

that describes what action occurred. ◦ When the control receives the message, it

generates an appropriate message response. Event Monitoring

◦ The state that the system is in after an event has completed execution but before a new event is detected.

McManusCOP1006 31

Page 32: Object-Oriented Programming

Exists when using event-driven languages Exists between screens and/or between the

user and the computer. Produces a non-linear application. Uses navigational tools

McManusCOP1006 32

Page 33: Object-Oriented Programming

Include ◦ Command buttons that can

Move forward or backward Quit the program Menu buttons

◦ Hot spots Planning MUST be used to make the

navigation user-friendly.

McManusCOP1006 33

Page 34: Object-Oriented Programming

Lesson17

McManusCOP1006 34

Page 35: Object-Oriented Programming

Success is measured by the amount of planning and inclusion of the user in the development process.

Include the user to give them warm fuzzies◦ This leads to buy-in by the client and user.

McManusCOP1006 35

Page 36: Object-Oriented Programming

Never lose sight of the purpose or the message.

Keep it simple!

Be consistent.

Design the navigation with the user in mind.

Understand when you can break the rules.

McManusCOP1006 36

Page 37: Object-Oriented Programming

Determine the◦ Requirements of the program

Input and output

◦ Classes of data Including properties and their attributes and the

functions (operations) of each class

◦ Interactivity Between classes and between the functions within

classes

◦ Instructions to accomplish each function.

McManusCOP1006 37

Page 38: Object-Oriented Programming

Is◦ Pleasant to look at◦ Functional◦ Provides easy access to its functions◦ Provides easy to understand instructions on the

functionality of the application◦ Allows the user to move through the program

non-linearly◦ Provides the ability to quit the program

McManusCOP1006 38

Page 39: Object-Oriented Programming

McManusCOP1006 39

Page 40: Object-Oriented Programming

Define the audience & the environment.◦ Know your audience◦ Know the environment in which the program will

be set

McManusCOP1006 40

Page 41: Object-Oriented Programming

Create the storyboards◦ Useful in designing the way your screen will

appear to the user.◦ It’s easier to take an eraser to paper than

redoing the screen ◦ Even loosely defined, this is basically the same

as creating a structure chart for the project◦ Example of storyboard

http://saulcarliner.home.att.net/id/storyboard.htm#screen

McManusCOP1006 41

Page 42: Object-Oriented Programming

McManusCOP1006 42

Page 43: Object-Oriented Programming

Define all objects◦ Screens are made up of objects◦ Developed

Within the software application In through an outside source

◦ Create an object dictionary Similar to a data dictionary

McManusCOP1006 43

Page 44: Object-Oriented Programming

Define the interactivity between screens.◦ Chart the interaction between the different

screens. Some may loop back on themselves Some may only go forward through a process

McManusCOP1006 44

Page 45: Object-Oriented Programming

Define the “scripts” (or modules)◦ Short sets of instructions attached to objects (or

to the entire application)◦ Includes the private functions that give the object

its functionality

McManusCOP1006 45

Page 46: Object-Oriented Programming

McManusCOP1006 46

Page 47: Object-Oriented Programming

McManusCOP1006 47