<- Previous Page Next Page ->

Basic Terms in Object Oriented Programming

It is necessary to understand some of the terms or concepts used extensively in object oriented programming before we go for further studies. The concepts behind these terms are not terribly complicated, but they can be hard to explain. Like most useful fields of study, you must work with it a while before it all clicks together in your mind. As each concept becomes clear, you will gain a deeper understanding of the subject. That said, you don't have to understand every thing about object oriented programming on the first pass to make good use of the concepts.

 The basic terms that you ought to know about OOP concept are-

 (a) Objects (b) Classes (c) Inheritance (d) Polymorphism

Besides, you need to learn about Data abstraction, Data encapsulation, Dynamic binding, Message passing, E-R relationship as they will help you to understand OOP’s advantages and OOP concept.

All these are detailed as bellows:

Objects:

Objects are the central idea behind OOP. The idea is quite simple.

An object is a bundle of variables and related methods.

A method is similar to a procedure. A method is an operation which can modify an objects behavior. In other words, it is something that will change an object by manipulating its variables. Like ‘functions’ in C or C++.

The basic idea behind an object is that of simulation. Most programs are written with very little reference to the real world objects the program is designed to work with; in object oriented methodology, a program should be written to simulate the states and activities of real world objects. This means that apart from looking at data structures when modeling an object, we must also look at methods associated with that object, in other words, functions that modify the objects attributes. That is, both attributes and functions of an entity (single object) are all together called ‘object’.

Now the question arises what are the attributes. Object can be a person, a place, a bank account, a table of data or any item that the program must handle. When a program is executed, the objects interact by sending message to one another. These messages depend on the kind of variables or data types that are being used in that object. The following example will make it clearer. In a program it is an object known as student. Under this object the data or attributes are Name, Date of birth, Marks etc. These attribute i.e. variables will be used to interact with other objects or to manipulate in other functions. In a sense these are the characteristics of the object.  Under ‘student’ the data functions are Total, Average and display. Both this attributes and functions make up this whole as an object.

Figure- O (1)

Text Box: Object: Student

 

Procedural programming divides the programming problem into two parts: data and operations on that data. Because all of the functionality of a procedural program works on the same set of data, the programmer must be very careful to manipulate the data of a program in such a way that the rest of the program can work correctly. He must be aware of the entire program at a low level of abstraction so as not to introduce errors. As a procedural program grows in size, the network of interaction between procedures and data becomes increasingly complex and hard to manage. In OOP, the concept of object eliminates this problem.

Object Oriented Programming (OOP) restructures the programming problem to allow for a higher level of abstraction. It groups operations and data into modular units called objects. These objects can be combined into structured networks to form a complete program, similar to how the pieces in a puzzle fit together to create a picture. In contrast to procedural programming, it focus on the interaction between data and functions, the design of objects and the interactions between those objects become the primary elements of object oriented program design.

By breaking down complex software projects into small, self-contained, and modular units, object orientation ensures that changes to one part of a software project will not adversely affect other portions of the software. Object orientation also aids software reuse. Once functionality is created in one program, it can easily be reused in other programs.

When a program is executed, the objects interact by sending message to one another.  For example let us assume there is another object called ‘Marks’ which include the data Name (two objects can have same entity and function), Marks, Course etc. and associated functions are Total, Average, Display, Grade etc. Here the first object ‘student’ can communicate with the second object ‘Marks’ through the common data or functions. Any data can be called only and only by its respective functions. This is also known as data abstraction.

Objects are uniquely identifiable by a name. Therefore you could have two distinguishable objects with the same set of values. This is similar to traditional programming languages where you could have, say two integers i and j both of which equal to 2. Please notice the use of ‘I’ and ‘j’ in the last sentence to name the two integers. We refer to the set of values at a particular time as the state of the object.

In other words, an object is an instance of a class. It can be uniquely identified by its name and it defines a state which is represented by the values of its attributes at a particular time.

Classes:

A class is a blueprint for an object.

What this basically means is that we provide a blueprint, or an outline of an object. This blueprint is valid whether we have one or one thousand such objects. A class does not represent an object; it represents all the information a typical object should have as well as all the methods it should have. A class can be considered to be an extremely extended TYPE declaration, since not only are variables held but methods too. It therefore provides implementation details for the data structure used and operations.

A class is an actual representation of an Abstract Data Type (ADT). A class is the implementation of an abstract data type (ADT). It defines attributes and methods which implement the data structure and operations of the ADT, respectively. Instances of classes are called objects. Consequently, classes define properties and behavior of sets of objects.

Actually the concept of class should come first rather than the concept object. Once a class has been defined, we can create any number of objects belonging to that class. For example, mango, apple and orange are members of the class fruit. If fruit has been defined as a class than the statement fruit mango will create an object mango belonging to the class fruit. All the objects in a class will share some common property. Some will less, some will more. This depends on inheritance.

A class is the actual implementation of an ADT. For example, an ADT for integers might include an operation set to set the value of its instance. This operation is implemented differently in languages such as C or Pascal. In C the equal sign ‘=’ defines the set operation for integers, whereas in Pascal the character string ‘:=’ is used. Consequently, classes implement operations by providing methods. Similarly, the data structure of the ADT is implemented by attributes of the class.

A variable whose type is a class is a class object. This can also be said as a object (which we say here as a variable) belonging to a class. Variable of any class means a object of that class. The basics of class can be represented as follows-

 Text Box: Class: Fruit
Text Box: DATA:
            Colour
            Taste
Text Box: FUNCTIONS:
            Cost
            Size
 

 

 

 

 

 

 

 

 

Figure: I (1); representing inheritance

In the real world, there are often many objects of the same kind, or type. My stereo (MP3 or other music format playing electronic device) is just one of many stereos that exist in the world. In the lingo of object oriented programming, each stereo is an instance. An instance of an object has its own state and leads an existence, independent of all other instances. My stereo probably has a very different collection of music than yours. But just as all stereos have the same set of buttons-allowing the same set of operations (play, stop, etc.)-all instances of a particular object expose the same functionality to the outside world.

You probably noticed that the illustrations of objects and classes look very similar. And indeed, the difference between classes and objects is often the source of some confusion. In the real world, it's obvious that classes are not themselves the objects they describe: A blueprint of a fruit is not a fruit. However, it's a little more difficult to differentiate classes and objects in software. This is partially because software objects are merely electronic models of real-world objects or abstract concepts in the first place. But it's also because the term "object" is sometimes used to refer to both classes and instances.

An object may be defined by class. Think of a class as a blueprint for making object instances. It provides all the information needed to build new instances of an object. Each class defines the internal variables that hold the data of an object instance and the ways, or methods. A class A is called ‘abstract class’ if it is only used as a super class for other classes.

When creating fruits, God must have taken advantage of the fact that fruits share characteristics, creating many fruits from the same blueprint. It would be very inefficient to produce a new blueprint for every individual fruit created. In object-oriented software, it's also possible to have many objects of the same kind that share characteristics: rectangles, employee records, video clips, and so on. Like the God, you can take advantage of the fact that objects of the same kind are similar and you can create a blueprint for those objects. Hence sometimes we call object oriented programming as the ‘language of God’.

Page-4

<- Previous Page Next Page ->