21
Object Oriented Object Oriented Programming Programming Dr. Ennis- Dr. Ennis- Cole Cole CECS 5100 CECS 5100

Object Oriented Programming Dr. Ennis-Cole CECS 5100

Embed Size (px)

Citation preview

Page 1: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Object Oriented Object Oriented ProgrammingProgramming

Dr. Ennis-ColeDr. Ennis-Cole

CECS 5100CECS 5100

Page 2: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Object Oriented Object Oriented ProgrammingProgramming

StepsSteps: :

1.) Visual Design1.) Visual Design

2.) Code Writing2.) Code Writing

Page 3: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Object Oriented Object Oriented Programming Programming

Controls toolbar, P. 23Controls toolbar, P. 23

Page 4: Object Oriented Programming Dr. Ennis-Cole CECS 5100

OOP - Visual OOP - Visual C++ C++

MFCMFC

Microsoft Foundation Class Microsoft Foundation Class

* Wizards to develop applications* Wizards to develop applications

* MFC AppWizard (dll) - * MFC AppWizard (dll) - generates source files and generates source files and

resource files resource files

Page 5: Object Oriented Programming Dr. Ennis-Cole CECS 5100

OOP - Visual C++ OOP - Visual C++

MFCMFC

MFC AppWizard (exe) - larger exe MFC AppWizard (exe) - larger exe files files

MFC Active X Control Wizard - MFC Active X Control Wizard - creates starter files for plug-inscreates starter files for plug-ins

Page 6: Object Oriented Programming Dr. Ennis-Cole CECS 5100

OOP Visual C++ OOP Visual C++

MFC

MFC Active X Control Wizard - multimedia, db, client server applications

MFC ATL Wizard - Active Template Library - objects, controls

Page 7: Object Oriented Programming Dr. Ennis-Cole CECS 5100

OOP - Visual C++OOP - Visual C++

Developer Studio - integrated tools for Developer Studio - integrated tools for creating, testing, and refining creating, testing, and refining applications.applications.

Complete development environmentComplete development environment

Page 8: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Popularity of Visual Popularity of Visual C++ C++

A. Code ReusabilityA. Code Reusability

B. Application Wizards (dlls, Active X, B. Application Wizards (dlls, Active X, Atl Com Objects)Atl Com Objects)

C. Integrated development environmentC. Integrated development environment

D. Components and Controls Gallery D. Components and Controls Gallery

(reusable components & controls)(reusable components & controls)

Page 9: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Popularity of Visual Popularity of Visual C++ C++

E. Support for MFC LibraryE. Support for MFC Library

F. PortabilityF. Portability

G. Cross Platform supportG. Cross Platform support

H. Availability in other languagesH. Availability in other languages

I. Supports latest C++ featuresI. Supports latest C++ features

Page 10: Object Oriented Programming Dr. Ennis-Cole CECS 5100

OOP - Visual C++OOP - Visual C++ Day 1: Day 1: Directory, Project, MFC AppWizardDirectory, Project, MFC AppWizard Used pushbutton controls in a dialog boxUsed pushbutton controls in a dialog box Attached the (BN_CLICKED) event to the Attached the (BN_CLICKED) event to the

pushbuttonpushbutton Classes Created: CHelloApp & CHelloDlgClasses Created: CHelloApp & CHelloDlg Prefixes: Functions ON_WM; Messages Prefixes: Functions ON_WM; Messages

WM_; Objects IDC_; Dialog Boxes IDD_WM_; Objects IDC_; Dialog Boxes IDD_

Page 11: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Object Oriented Object Oriented ProgrammingProgramming

OOP - a programming technique that relies OOP - a programming technique that relies on reusable software components that can on reusable software components that can be applied to different types of problems be applied to different types of problems and applications. The programmer makes and applications. The programmer makes the machine work in terms of concepts the machine work in terms of concepts closer to the user’s every day world. closer to the user’s every day world.

Principle unit - Principle unit - An ObjectAn Object

Page 12: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Objects Objects

Separate Components :Separate Components :• Say HelloSay Hello• ExitExit• Each had its own Caption & ID (IDC_…)Each had its own Caption & ID (IDC_…)

Belonged to the CHelloDlg Class Belonged to the CHelloDlg Class An instance of CHelloDlg ClassAn instance of CHelloDlg Class Created within the Visual EnvironmentCreated within the Visual Environment

Page 13: Object Oriented Programming Dr. Ennis-Cole CECS 5100

ObjectsObjects

Private data ( ) Private data ( ) Procedures that could access that data Procedures that could access that data

• written in the CHelloDlg Classwritten in the CHelloDlg Class• Member functions:Member functions:

– OnSayhelloButton( )OnSayhelloButton( )

– OnExitButton( )OnExitButton( )

A program can be thought of as a collection A program can be thought of as a collection of objectsof objects

Page 14: Object Oriented Programming Dr. Ennis-Cole CECS 5100

ObjectsObjects

MessagesMessages• BN_CLICKEDBN_CLICKED• BN_DOUBLECLICKEDBN_DOUBLECLICKED

Respond to predefined external stimuli Respond to predefined external stimuli • Mouse ClickMouse Click

Communication Communication • Represent the events to which an object can Represent the events to which an object can

respondrespond

Page 15: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Structure of a Structure of a FunctionFunction

void void reference, Class reference, Class name ::, function name ::, function

name, ( ), {, name, ( ), {, Comments, Attached Comments, Attached

Code, Comments, }Code, Comments, }

Page 16: Object Oriented Programming Dr. Ennis-Cole CECS 5100

ClassesClasses

Case sensitivityCase sensitivity Properties Tables, P. 43 Properties Tables, P. 43 Group Box, P. 52, Properties Table, P. 59Group Box, P. 52, Properties Table, P. 59 Variables - storage containers:Variables - storage containers:

• Memory LocationMemory Location• Amount of Memory Amount of Memory • m_TestEdit = “ ”;m_TestEdit = “ ”; 20

FFFA, 2 bytes

Num1

Page 17: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Variables - Changeable Variables - Changeable Quantities Quantities

An actual representation of a data typeAn actual representation of a data type• ValueValue IntegerInteger• CSTRINGCSTRING CharacterCharacter• BOOLBOOL Double, FloatDouble, Float

Other Functions:Other Functions:• MessageBox(“ ”); MessageBox(“ ”); • UpdateData(False); - updates screen w/new UpdateData(False); - updates screen w/new

valuesvalues

Page 18: Object Oriented Programming Dr. Ennis-Cole CECS 5100

New Windows New Windows Controls Controls

Edit Box, Check Box, Static, Group Edit Box, Check Box, Static, Group BoxBox

Right Click on on your mouse for Right Click on on your mouse for property Settingsproperty Settings

Use P. 59 for your object’s propertiesUse P. 59 for your object’s properties

Introduction of Keyboard ShortcutsIntroduction of Keyboard Shortcuts

Page 19: Object Oriented Programming Dr. Ennis-Cole CECS 5100

Windows Windows ProgramsPrograms

CalculatorCalculator Paint Paint Invoked via entries in the the Edit Invoked via entries in the the Edit

Box ab| (Calculator or Paint)Box ab| (Calculator or Paint)

Page 20: Object Oriented Programming Dr. Ennis-Cole CECS 5100

EventsEvents Linked with messagesLinked with messages After communication between After communication between

objects, some action takes place. objects, some action takes place. This action has the code in it to This action has the code in it to perform a set task - initialize a perform a set task - initialize a dialog box, paint, execute a system dialog box, paint, execute a system command.command.

Page 21: Object Oriented Programming Dr. Ennis-Cole CECS 5100

The End The End

““That’s all folks.”That’s all folks.”