Chapter 1 Introduction to Object-oriented Programming and ...

glintplainvilleSoftware and s/w Development

Nov 18, 2013 (3 years and 6 months ago)



Chapter 1 Introduction to Object
oriented Programming and Software Development


Before we begin to write actual programs, we need to introduce a few basic concepts of

oriented programming
, the style of programming you will learn

in this book. The purpose of this
chapter is to give you a feel for object
oriented programming and to introduce a conceptual
foundation of object
orienting programming. You may want to refer back to this chapter as you
progress through the book.

r purpose of this chapter is to introduce the software development process. To be able to
write programs, knowing the components of object
oriented programs is not enough. You must
learn the process of developing programs. We will provide a brief descri
ption of the software
development process in this chapter.


Classes and Objects

The two most important concepts in object
oriented programming are the class and the object. In
the broadest term, an object is a thing, both tangible and intangible, that we

can imagine. A
program written in object
oriented style will consist of interacting objects. For a program to
maintain bank accounts for a bank, we may have many Account, Customer, Transaction, and ATM
objects. An object is comprised of data and operat
ions that manipulate these data. For example, an
Account object, may consist of data such as account number, owner, date opened, initial balance,
and current balance and operations such as deposit, transfer, and withdrawal. We will use the
diagram shown i
n Fig. 1.a throughout the book to represent an object.

Almost all nontrivial programs will have many objects of the same type. For example, in the bank
program we expect to see many Account, Customer, and other objects. Fig.1.2 shows two
Customer object
s with the names Jack and Jill and one Account object with the name SV129.

Inside a program we write instructions to create objects. For the computer to be able to create an
object, we must provide a definition, called a
. A class is a kind of mold

or template that the
computer uses to create objects. An object is called an

of a class. An object is an instance
of exactly one class. An instance of a class belongs to the class. The tow Customer objects Jack and
Jill are instances of the Cus
tomer class. Once a class is defined, we can create as many objects of te
class as a program requires.