Object Oriented Programming Concepts (OOPS)

       
Well You must have heard about this term OOPs Concept if your are a Computer Science
Graduate . What is this term "OOPs"  ? Why this Concept was Introduced ?

Earlier their were some Popular Programming Languages like ALGOL FORTRAN COBOL and  BASICPascal and were introduced around  1970's.These were 
procedural Programming languages ( derived from Structured Programming)

Lets Understand this with help Of C , which is a Structured Programming Language
Its One of Powerful and most Popular Language since 1980's .This language has very

much dependent of modular approach .

if we analyse the  Language we will find two Major drawbacks in C Language

will lead to  the Concepts called Object Oriented Concepts - 

First Lets see those two major drawbacks and later we will understand how Object 
Oriented Programming Overcomes this drawback.

1)  C Programming Codes are lengthy and has Complex Structure

      
In C Programming for everthing you have to write a functions and then call
the functions in other words it so much function dependent that makes it's 
efficiency bit complex 
      
2)  Security Concerns of  Data Members (Structure & Union)

if  you have heard about this Structure Union Concepts you know Its Collection of One or More variables preferably of different data types combines it into a i single type of type Struct.
E.g

Lets say we have Structure of Type Student  with 3 Fields Id, Name and City .
Make a Structure variable named  'Std'

struct Student //Declaring Structure Of Type Student
{
int Id;
   char Name[20];
   char City[20];
};

Student Std; //Structure variable Of Type Std

Now Lets assign the value to the Data Members of  Student with Student variable Std .For this we need to  do following  two things -
a) Access the Data Members With Std variable (Use Dot Operator)
Std.id , Std.Name,Std.City

b)Assign the Value to the Respective Data Members
As we have reached the respective data members using Std Varibale directly we can assign any value
(Garbage or Non Garbage) to the variable .Like Someone may go and assign negative value of Id or id value as 0 which in not possible Id neither be negative or Zero

Ahhh will you still say Secured for our Data Members (Properties) ?

Answer is NO , No , & No .

Why we expose our Data Members directly to Others Out Side using Just Structure variable
with our Dot Operator. Any Solutions to this ?

Now Here Object Oriented Programming Concepts  comes and says wait , i have one solution  for this i will provide a Behavior (Member Functions) to Regulate the activity to be done of Data Members .Now i will not allow the Data Members to access Directly . What ever Changes you need to make or get of Data Members i will play a mediator role between  Out side Variables accessing and Inside Data Members.

This is Reason Data Members and Members Functions are Binded  together so that It can be protected from Outside world ,This Concept of Binding is Called ENCAPSULATION 
The Mechanism which is used to Implement this Encapsulation is called  CLASS.











Rahul Singh

As a passionate software developer, trainer, and tech blogger, I thrive on sharing knowledge and exploring the latest in technology. With a strong foundation in programming languages like C and C++, and expertise in platforms like Microsoft 365, SharePoint, and Azure, I aim to simplify complex concepts for others. My blog, Expert2Code.com, is a space where I document my learning journey, providing insights and resources for those eager to master the tech world. When I'm not coding or teaching, you'll find me reading, hiking, or discovering new tools and techniques to stay ahead in this fast-paced industry.

Post a Comment

Previous Post Next Post