Object Oriented Programming
The software evolution occurred in several phases. Since the beginning of the first computer, programming for the computer started to develop software. The earlier electronic computer ENIAC was programmed in machine language by using switches to enter 1 and 0.
In procedure oriented programming a large program is broken down into smaller manageable parts called procedures or functions. In procedure oriented programming priority is given on function rather than data. In procedure oriented programming language, a program basically consists of sequence of instructions each of which tells the computer to do something such as reading inputs from the user, doing necessary calculation, displaying output. High Level Programming Languages like COBOL, FORTRAN, Pascal, C are common procedure oriented programming languages.
Object-oriented Programming:The fundamental idea behind object-oriented programming is to combine or encapsulate both data (or instance variables) and functions (or methods) that operate on that data into a single unit. This unit is called an object. The data is hidden, so it is safe from accidental alteration. An object’s functions typically provide the only way to access its data. In order to access the data in an object, we should know exactly what functions interact with it. No other functions can access the data. Hence OOP focuses on data portion rather than the process of solving the problem.
Characteristics of OOPsSome noticeable characteristics of OOP are as follows:
• Emphasis is on data rather than procedures.
• Programs are divided into objects.
• Function and data are tied together in a single unit.
• Data can be hidden to prevent from accidental alteration from other function or objects.
• Data access is done through the visible functions so that communication between objects is possible.
• Data structures are modelled as objects.
• Follows Bottom up approach of program design methodology.
Characteristics of Object-Oriented Language
Objects are the basic run-time entities in an object-oriented language. They may represent a person, a place, a bank account, a table of data or any item that the program has to handle. They may also represent user-defined data such as vectors, time and lists. Program objects should be chosen such that they match closely with the real-world objects. Objects take up space in the memory.
A class is a collection of objects of similar types. Classes are user-defined data types and behaves like the built-in types of a programming language. A class also consists method (i.e. function). So, both data and functions are wrapped into a single class.
• It is the process by which objects of one class acquire the properties of another class.
• It supports the concept of hierarchical classification. In OOL, the concept of inheritance provides idea of reusability.
Object-oriented programs are built from reusable software components. Once a class is completed and tested, it can be distributed to other programmers for use in their own programs. This is called reusability. If those programmers want to add new features or change the existing ones, new classes can be derived from existing one. Reusability reduces the time of software development.
• Creating new data types: There are other problems with procedural language. One is the difficulty of creating new data types. Computer languages typically have several built-in data types: integers, floating point number, characters and so on. If you want to invent your own data types, you can. You want to work with complex number, two dimensional co-ordinates or dates, you can create data type complex, date, co-ordinate, etc.
• Polymorphism and Overloading:
• Polymorphism is another important characteristics of OOL. Polymorphism, a Greek term, means the ability to take more than one form. The process of making an operator to exhibit different behaviours in different instances is known as operator overloading. Using a single function name to perform different types of tasks is known as function overloading.
• For example, consider the operation of addition. For two numbers, the operation will generate a sum. If the operands are strings, then the operation would produce a third string by concatenation.
• All operator overloading and function overloading are examples of polymorphism.
• Polymorphism is extensively used in implementing inheritance.
Benefits of using OOP:
Object orientation programming promises greater programmer productivity, better quality of software and lesser maintenance cost. The principle advantages are:
• Through inheritance, we can eliminate redundant code & extend the use of existing classes.
• Reusability saves the development time and helps in higher productivity.
• It is possible to map objects in the problem domain to those in the program.
• It is easy to partition the work in a project based on objects.
• Object oriented systems can be easily upgraded from small to large system.
• Software complexity can be easily managed.
Application of using OOP:
• Real time system
• Simulation and modeling
• Object oriented databases
• Hypertext, hypermedia n/w containing interlinked information and expertext units.
• AI and expert system
• Neural networks and parallel programming.
• Decision support and office automation systems.