by Dinesh Thakur Category: Introduction to Java

The different languages reflect the different styles of programming. OOP or object-oriented programming is a style of programming with a firm basis in several concepts. Those concepts revolve around objects and classes and include Polymorphism, Encapsulation, Inheritance, Abstraction and more.  Java is one of the most popular of all the object-oriented programming languages, as well as one of the easiest to learn and use.   
Any application built on objects in Java is an object-oriented application and is based on the declaration of one or more classes, with an object created from those classes and the interaction between the objects.    

Traditional Programming Languages – Procedural-Oriented  

Traditional languages like Fortran, Pascal, C, and Cobol, are procedural-oriented languages and they have some drawbacks when it comes to reusing the components they built from.

Procedural programming decomposes a program into various different functional units, each of which can gather and manipulate data as needed.

Procedural-oriented languages built from functions and functions are not as easy to reuse as an object, or a class is. Copying a function from a program and then using it in another is not very easy because that function is more than likely going to reference other functions and global variables. In basic terms, a function is not encapsulated correctly as a unit that is self-contained and reusable.  

Also, procedural-oriented programming languages are not suited to solving real-world problems because they don’t have a high enough level of abstraction.  For example, in C programming we use constructs, like the for loop, if-else statements, methods, arrays, and pointers. These are all low-level and very hard to abstract a real-world problem from, like a computer football game or a CRM (Customer Relationship Management) system.  
In short, traditional languages, the procedural-oriented languages, separate the variables (the data structures) and the functions (the algorithms).    

Object-Oriented Programming  

Object-oriented programming, on the other hand, decomposes a program into various different data-oriented units or other conceptual units; each unit contains data and various operations that may be performed on that data. Procedural programming forced developers to write highly interdependent code.  

With object-oriented programming or OOP as it has become known, are designed to get around these kinds of problems. The basic OOP unit is a class, and a class will encapsulate both the static properties and the dynamic operations inside a  container or ‘box.’ It specifies what the public interface is for making use of these boxes too.  

Because the class is well-encapsulated, it is much easier to reuse. In short, OOP  combines the algorithms and the data structures that make up a software entity inside one box.  

With OOP languages we can use a much higher abstraction level,  allowing us to solve real-world problems. While a traditional language, the  procedural languages like Pascal and C force you to do your thinking in terms of  the computer structure, like bytes, memory, decisions, loops, and arrays, instead of  in terms of the problem that needs to be solved, the OOP languages, like Java,  allow you to do your thinking in the problem space. They make use of software objects that represent the problem space entities, and allow you to abstract them to find a solution to the problem.  

Let’s say, as an example, that you want to write a computer game based on football. Now, this is quite a complex type of game to build and using a procedural-oriented language would prove quite difficult. With an OOP language, it is much easier because the game can model according to real-life things that happen in the game. For example, your classes could be:  

● Player:  the attribute for a player would be name, location on the playing  field, number, etc. while the operations would include running, jumping, kicking the ball and so on.
●  Field  
●  Reference  
●  Weather  
●  Audience  Perhaps more importantly, some classes, like Audience, or Ball, could easily be  reused in a different application, perhaps a basketball game, without the need for  too much, if any, modification.

The Benefits of Using OOP  

Because procedural-oriented languages concentrate on procedures, using a basic  unit of a function, you need to spend time first working out what all of the functions are going to be and then thinking about how they should be represented.  With OOP languages, we focus our attention on the components perceived by the  user using a basic unit of an object. You work out what all the objects are by combining data with the operations that are used to describe the way a user interacts  with them.

The benefits of OOP include:  

Much easier to use in terms of designing software. Rather than thinking in terms of bytes and bits, you can think in terms of the problem space instead.  You are using abstraction and higher level concepts and, because the design is more comfortable, your application development is much more productive.  

The software is easier to maintain because it is much easier to understand. In turn,  that makes it easier to test and to debug.  

The software is reusable. There is no longer any need to keep writing the same functions repeatedly for different scenarios. Being able to reuse the same code is fast and safe because you are using code that has been thoroughly tested already and is proven to work.     

 We can summarize the differences as follows :

Procedural Programming

 top down design

 create functions to do small tasks

 communicate by parameters and return values

Object Oriented Programming

 design and represent objects

 determine relationships between objects

 determine attributes each object has

 determine behaviours each object will respond to

 create objects and send messages to them to use or manipulate their attributes.





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.