OOP :o :o :p (What is OOP , Why we want it)


     Hello Fellow Readers..  Welcome to inspire++ :) This post is specially for the people who are doing OOP now. Don't get confuse with this post , because we are still on the VARIABLES in our fundamental programming post series. OOP is a big set of lessons, so we have to do this also as a post series. This series will be continue parallel to our fundamental post series. OK... that being said..
Lets start..  

     When you have to create a big program , I mean really really big one , big enough to call it a software , we will have to do more and more coding. Sometimes we will have to re-type the same set of code-lines again and again. 


     This seems to be a big head-aching situation. So, as smart engineers what are the options do we have to do to reduce the time for coding and to reduce the pain occur when doing the same thing again and again.? 

     Well you might have the answer already. "C n P" or AKA Copy and Paste Method Right!! You type the set of code , copy it and paste wherever you want them to be in your source code. Easy!! 


     BUT!! it is not a wise method to follow for some Reasons. Imagine if there is an error or a Bug in your code , when you copy that set of codes to 20 different places in your source code , you will have the same error in 20 times and you will have to fix it 20 times repeatedly.  And imagine how your source code will look like. It will be very very long and it'll be really hard to keep working with .



  1. Duplicate code is a Bad Thing.
  2. More codes - Hard to work with. 

     So there is a big problem that haven't answered properly. Purpose of this post is to tell you how to solve this problem by introducing you the Concept of OOP-Object Oriented Programming. By the end of this post you will have an idea about what is OOP and Why we want it.


     Can you remember the lesson functions..Well in our Fundamental post series we haven't arrived that point yet, but I guess you guys have the idea of what is a function and how to use it..


     So in short, A function is a set of codes in your source code with a given name. It exist parallel to our main function. It does not do anything until we call it. Whenever we want we simply call the function in main function. 
     
     So instead of typing or copying the same set of code again and again in main function , we can create a function and call it when we want to execute them. This method is call function calling. So if there is any error in our code we only have to fix it in the function and whole program will fixed automatically. No need to fix same error 20 different places. 

     This concept is very helpful when understanding OOP. In software developing we use a developed version of this concept. Instead of using functions we use Classes and Objects  in OOP (Object Oriented Programming.) 

     By using Classes & Objects We Can,

  1.      Reduce duplicating codes.
  2.      Reduce the number of code lines in your main       function.

     And the whole program will become a User friendly neat and logical thing and it will be easy to work with. OK I think now you have an idea about why we want OOP right!!


     In OOP we create Classes - AKA the blueprints of the objects - Classes have Properties and Behaviors. And we create Objects (Real world things) using codes, and to make those objects feel real we encapsulate them, use inheritance and polymorphism to use them in advance. So as a terminology you can refer those red color words , those words will be the topics of our next posts. So stay with inspire++ to get a fully understand about OOP. Thank you guys..!! C U.. :) 
Next post>>>

No comments:

Post a Comment

“What do you think about this?”
“Do you agree?
Share your thoughts in the comments below!”

Life of a Systems Engineer

  Hello, my dear readers. ✌😀✋ I'm talking to you after a very long time. And I am thrilled to talk-to and hear-from you after all thi...