Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 1 - Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.

Similar presentations


Presentation on theme: "Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 1 - Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data."— Presentation transcript:

1 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 1 - Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data length width A set of functions area = length * width Then Applying functions to data to get answer

2 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 2 - Introduction to C++ Familiar languages C Pascal Basic Fortran Assembler Common thread among these……. All encapsulate functions and data in procedures

3 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 3 - Introduction to C++ In English area = length * width Mentally form model Compute Area 2 parameters Length, l Width, w 1 function area = l * w return area In C int compute_area (int l, int w) { return ( l * w ); } Find the Area of a Rectangle

4 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 4 - Introduction to C++ Abstracting the World Must ask several questions: 1. Should any arbitrary set of data and functions be grouped? 2. Are there preferred groupings? 3. If preferred groupings, how are these selected?

5 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 5 - Introduction to C++ Abstracting the World Procedural C, Basic, Pascal, Fortran Around Procedures Functional Lisp Around Functions Logical Prolog Around logical relationships Object Centered Smalltalk, C++, Objective C, Eiffel Around Objects Object Functions Data

6 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 6 - Introduction to C++ Introduction to Objects Objects are an Abstraction Represent Real World Entities Numbers Character strings Electronic Parts Signals Fruits Usually nouns…...

7 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 7 - Introduction to C++ Introduction to Objects Objects Have State Value At a particular time Electronic Part Conducting ON Signal Value Signal State value Electronic Part State conducting ON

8 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 8 - Introduction to C++ Introduction to Objects Actions or Operations Methods Describe how to carry out operations Usually verbs Electronic Part Enable Disable Activate Signal Add Scale Invert Signal State value Operations add scale invert Electronic Part State conducting ON Operations enable disable activate

9 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 9 - Introduction to C++ Introduction to Objects Set of Messages Request for object to carry out one of its operations Means to exchange data between objects Signal State 2 Operations add scale invert Signal State 3 Operations add scale invert ADD

10 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 10 - Introduction to C++ Object Oriented Programs Program Set of Objects Set of possible actions Exchange of messages Instructing a particular object To carry out one of its actions O2 program class instances messages O1 O3 O4

11 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 11 - Introduction to C++ Organizing Objects Classes Means for grouping Entities with Common Properties and Attributes Hierarchy Means for Organizing Classes into Subgroups of a Group

12 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 12 - Introduction to C++ Programming Languages Object Oriented Procedural Functional C++ Java C# Organizing Objects

13 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 13 - Introduction to C++ Organizing Objects Land Vehicles Air Sea Bicycle Automobile Truck

14 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 14 - Introduction to C++ Communicating with Objects Object Rectangle data - encapsulated Length, l Width, w function - encapsulated area = l * w In C++ class Rectangle { public: Rectangle() {l = 10; w = 22; } int area () { return ( l * w );} private: int l; int w; }

15 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 15 - Introduction to C++ Encapsulating Objects Information Hiding Abstraction Encapsulation

16 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 16 - Introduction to C++ Encapsulating Objects - Information Hiding Want to Make Certain Unnecessary Details Inaccessible Motivation Reduce number of details need to deal with Want interaction among objects simple as possible

17 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 17 - Introduction to C++ Encapsulating Objects - Information Hiding Key to object oriented thinking Must have good strategy Can not simply hide Object Is black box Must have well defined interface Only access through methods specified in interface No access to internals

18 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 18 - Introduction to C++ Encapsulating Objects - Abstraction Strategy for information hiding Consider the details…... Ignore Unessential Less important Focus On essential More important

19 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 19 - Introduction to C++ Encapsulating Objects - Abstraction Levels of Abstraction Higher More important details Lower Shift focus to lower Types of Abstraction Data Data used becomes a high level concept Functional Function to be performed becomes a high level concept

20 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 20 - Introduction to C++ Encapsulating Objects - Encapsulation Packaging of related entities Logically Physically Treat packaged items as unit - Usually the nouns These will be the objects

21 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 21 - Introduction to C++ Encapsulating Objects List Contents Items in list State Information Number of items in the list Operations Add Delete Length Copy Exceptions Overflow Underflow Exportable Items Empty List

22 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 22 - Introduction to C++ Definitions What is object oriented programming……. Not –Programming with objects –Programming with an object oriented language –Moving objects around on a screen

23 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 23 - Introduction to C++ Definitions Must support 4 fundamental criteria….. Must support abstraction Focus on essential details While ignoring non-essential Must support abstract data types ADT is a model Encompasses Type Int, char, string Set of Operations These characterize the behavior of the type

24 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 24 - Introduction to C++ Definitions Must support inheritance Ability to derive new objects from old Makes the language extensible Must support polymorphism Specifies how objects Respond to certain kinds of messages

25 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 25 - Introduction to C++ Summary Information hiding Process of making certain items inaccessible Abstraction Strategy for information hiding Focus attention on certain details Ignore others Encapsulation Packaging mechanism In object oriented paradigm Objects are the encapsulation Objects Complete entities….. Data + Functions Highly independent with a means for interaction

26 Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 26 - Introduction to C++ Summary A program consists of a collection of Data Functions Programming methodology characterized by How data and functions are encapsulated Procedural Functional Logical Object Centered


Download ppt "Copyright 2006 Oxford Consulting, Ltd1 January 2006 - 1 - Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data."

Similar presentations


Ads by Google