by Dinesh Thakur Category: Object-oriented programming (OOP)

(OOPL) A programming language specifically designed to support the writing of OBJECT-ORIENTED programs. Such languages typically support three features not found in traditional programming languages: CLASSES, ENCAPSULATION and INHERITANCE, though the actual constructs that embody these features may have different names in different languages. The first such OOPL to be invented was SIMULA, and the most widely used OOPL today is C++, which is a derivative of the C language with added object-oriented features. Other important OOPLs include JAVA, OBJECT PASCAL, EIFFEL, and the historically important SMALLTALK.

A class is a template that describes the structure and behaviour of any number of similar objects, which are bundles of related data values. A class definition is in two parts, a data part and a code part. The data part describes a collection of named slots called INSTANCE VARIABLES, copies of which will be contained in every INSTANCE (Le. object) of that class. At run time these will be filled with different values representing the properties of each individual object. Imagine a class as being like a cl1equebook; then creating a new instance means tearing out one cheque and filling it in.

The code part defines a collection of named subroutines called METHODS which have access to the instance variables and may manipulate their contents. ENCAPSULATION refers to the fact that, in a purely object-oriented language, the only way to access the data stored in each object is by executing one of these methods, as the data is otherwise entirely hidden from other objects in the program. When a program that uses several classes is run, it creates named INSTANCES of these classes, and it is these objects and the data that they contain that are manipulated by the program, not the classes themselves (just as you give the grocer a cheque, not your chequebook). Execution proceeds by objects calling each others' methods, and data may be transferred between objects via the PARAMETERS passed in such calls.

INHERITANCE permits new classes to be derived from previously defined classes, and is a powerful conceptual tool for organizing related classes in a hierarchical fashion. Suppose that a class called 'aircraft' has been defined, with instance variables 'wingspan' and 'number_of_engines'. A new SUBCLASS called 'airliner' that inherits from 'aircraft' would automatically have these instance variables (and all the methods too) without having to redefine them, but may add to them some more specific variable such as 'number_of-passengers' that does not apply to all aircraft. Inheritance proceeds by specializing, from the general to the particular.

In a pure object-oriented programming language, all data must be contained in objects, and programs consist solely of method calls, whereas a hybrid language permits object references and method calls to be mixed with conventional program code that may access the data inside objects directly, and may employ other data structures besides objects. JAVA and SMALLTALK are pure OOPLs whereas c++, OBJECT PASCAL and VISUAL BASIC are hybrids.



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles