Structured Programming vs. Object-Oriented Programming

Overview

Newbie programmers are often baffled with programming methodology and programming language. Methodology is concerned with the way you write a program. Commonly known programming methodologies are structured programming, procedural programming, object oriented programming, etc. It is possible to write a program using object-oriented programming language with structured programming methodology. There are two most commonly known programming methodologies –

  1. Structured Programming
  2. Object-Oriented Programming

Structured Programming

In 1970 and 1980, popular programming methodology was structured programming. Structured programming methodology is based on following process –

  1. Break down a large problem into several sub-parts
  2. Treat each part as a new problem and work on it
  3. Repeat the process with each new part until each part can be solved independently, without further decomposition

This idea of development is known as program development by stepwise refinement. As I stated earlier, it is possible to write a program in object-oriented programming language such as Java, C# with structured programming methodology.

Example (C Language) –

[code language="c"]

#include <stdio.h>
#define PI 3.141

float calculateTriangleArea(float base, float height)
{
float area;
area = 0.5 * base * height;
return area;
}

float calculateRectangleArea(float width, float height)
{
float area;
area = width * height;
return area;
}

float calculateCircleArea(float radius)
{
float area;
area = PI * radius * radius;
return area;
}

int main()
{
float area;

area = calculateRectangleArea(2.5, 3);

printf("Area of Rectangle: %f", area);

area = calculateCircleArea(2.5);
}

[/code]

Object-Oriented Programming

Most important features of object-oriented programming are inheritance, polymorphism and encapsulation.

1 Comments

  1. I do believe all of the concepts you have introduced to your post. They are really convincing and can definitely work. Still, the posts are too quick for newbies. May you please prolong them a bit from next time? Thanks for the post.

    Reply

Leave a Comment.