Java Oops Fundamentals Tutorial
Introduction to OOPs Programming
OOPs vs Traditional Programming Styles
Basic Concepts of OOPs
Garbage Collection In JVM
Constructor and Its Types
Encapsulation In OOPs
Inheritance in OOPs
Polymorphism in OOPs
Abstraction In OOPS
Author Profile Altaf Shaikh
Altaf Shaikh

BE Engg | Python Dev | Content Writer | Founder of TeachMeBro | Blockchain Dev | Django

OOPs vs Traditional Programming Styles

October 15th 2020

OOPs vs Traditional Programming Styles
OOPs vs Traditional Programming Styles

Comparison of OOPs vs Traditional Programming Styles 

Let's understand with an example how OOPs is different than other programming approaches.

Programming languages can be classified into 3 primary types:

  1. Unstructured Programming Languages: The most primitive of all programming languages having sequentially flow of control. The code is repeated throughout the program. Examples- BASIC, COBOL, and FORTRAN.
  2. Structured Programming Languages: Has a non-sequentially flow of control. The use of functions allows for re-use of code. Examples- Java, Python, C++
  3. Object Oriented Programming: Combines Data & Action Together. Examples- Java, Python, C++

Let's understand these 3 types with an example:

Suppose you want to create a Banking Software with functions like

  1. Deposit
  2. Withdraw
  3. Show Balance

Unstructured Programming Languages

The earliest of all programming languages were unstructured programming languages. A very elementary code of banking application in unstructured Programming language will have two variables of one account number and another for account balance

int account_number=20;

int account_balance=100;

Suppose a deposit of 100 dollars is made.

account_balance=account_balance+100

Next, you need to display account balance.

printf(“Account Number=%d,account_number)

printf(“Account Balance=%d,account_balance)

Now the amount of 50 dollars is withdrawn.

account_balance=account_balance-50

Again, you need to display the account balance.

printf(“Account Number=%d,account_number)

printf(“Account Balance=%d,account_balance)

 

For any further deposit or withdrawal operation – you will code repeat the same lines again and again.

Structured Programming

With the arrival of Structured programming repeated lines on the code were put into structures such as functions or methods. Whenever needed, a simple call to the function is made.

Object-Oriented Programming

In our program, we are dealing with data or performing specific operations on the data.

In fact, having data and performing certain operations on that data is a very basic characteristic in any software program.

Experts in Software Programming thought of combining the Data and Operations. Therefore, the birth of Object Oriented Programming which is commonly called OOPS.

The same code in OOPS will have the same data and some action performed on that data.
 

Class Account{

    int account_number;

    int account_balance;


    public void showdata(){

       system.out.println(“Account Number”+account_number)

       system.outprintln(“Account Balance”+ account_balance)
   }

}