oop3 - Chapter 3 Object Oriented Programming Concepts 3.1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 3 Object Oriented Programming Concepts 3.1 Introduction The use of Object Oriented (OO) design and Object Oriented Programming (OOP) are becoming in- creasingly popular. Thus, it is useful to have an introductory understanding of OOP and some of the programming features of OO languages. You can develop OO software in any high level language, like C or Pascal. However, newer languages such as Ada, C++, and F90 have enhanced features that make OOP much more natural, practical, and maintainable. C++ appeared before F90 and currently, is prob- ably the most popular OOP language, yet F90 was clearly designed to have almost all of the abilities of C++ . However, rather than study the new standards many authors simply refer to the two decades old F77 standard and declare that Fortran can not be used for OOP. Here we will overcome that misinformed point of view. Modern OO languages provide the programmer with three capabilities that improve and simplify the design of such programs: encapsulation, inheritance, and polymorphism (or generic functionality). Related topics involve objects, classes, and data hiding . An object combines various classical data types into a set that defines a new variable type, or structure. A class unifies the new entity types and supporting data that represents its state with routines (functions and subroutines) that access and/or modify those data. Every object created from a class, by providing the necessary data, is called an instance of the class. In older languages like C and F77, the data and functions are separate entities. An OO language provides a way to couple or encapsulate the data and its functions into a unified entity. This is a more natural way to model real-world entities which have both data and functionality. The encapsulation is done with a “module” block in F90, and with a “class” block in C++. This encapsulation also includes a mechanism whereby some or all of the data and supporting routines can be hidden from the user. The accessibility of the specifications and routines of a class is usually controlled by optional “public” and “private” qualifiers. Data hiding allows one the means to protect information in one part of a program from access, and especially from being changed in other parts of the program. In C++ the default is that data and functions are “private” unless declared “public,” while F90 makes the opposite choice for its default protection mode. In a F90 “module” it is the “contains” statement that, among other things, couples the data, specifications, and operators before it to the functions and subroutines that follow it. Class hierarchies can be visualized when we realize that we can employ one or more previously defined classes (of data and functionality) to organize additional classes. Functionality programmed into the earlier classes may not need to be re-coded to be usable in the later classes. This mechanism is called inheritance . For example, if we have defined an....
View Full Document

This note was uploaded on 05/16/2010 for the course COMPUTER S WXES1110 taught by Professor Dr.liangng during the Spring '09 term at University of Malaya.

Page1 / 17

oop3 - Chapter 3 Object Oriented Programming Concepts 3.1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online