object-oriented programming

Post on 04-Jan-2016

33 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

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

Lesson 16

McManusCOP1006 1

OOP◦Classes◦Objects◦Inheritance◦Functions

GUI

Event-driven Object-Oriented Programming◦Events◦Interactivity

McManusCOP1006 2

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

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

McManusCOP1006 4

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

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

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

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

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

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

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

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

13

Looks Yummy!

I’m sure gladI don’t have to eat

this stuff!

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.

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?

McManusCOP1006 16

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

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

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

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

McManusCOP1006 20

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

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

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

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

A collection of like items or objects. Examples

◦ Books◦ Clients◦ Waiter◦ Cook

McManusCOP1006 25

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

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

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

Each language has own set of events Examples of events

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

McManusCOP1006 29

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

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

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

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

Lesson17

McManusCOP1006 34

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

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

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

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

McManusCOP1006 39

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

be set

McManusCOP1006 40

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

McManusCOP1006 42

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

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

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

McManusCOP1006 46

McManusCOP1006 47

top related