Skip to main content

What is Object-Oriented Programming? The concept of Class and Objects

what is oop-image
Object-Oriented Programming is a powerful way to address the task of programming. Programming methodologies have improved dramatically since the invention of the computer, primarily to support the growing complexity of programs.
For example, when computers were first invented, programming was done by toggling in the binary machine instructions using the computer's front panel. As long as programs were just a several hundred instructions long, this way worked. As programs grew, assembly language was invented so that a programmer could deal with bigger, more complex programs, using symbolic representations of the machine instructions. As programs continued to grow, high-level languages were introduced that gave the programmer more tools with which to handle complexity.
The 1960s gave birth to structured programming. This is the approach supported by languages such as C and Pascal. The use of structured languages made it possible to write somewhat complex programs fairly easily. Structured languages are characterized by their support for stand-alone subroutines, local variables, rich control constructs, and their lack of dependence upon the GOTO. Although structured languages are a powerful tool, even they reach their limit when a project becomes excessively large. Consider this: At each milestone in the development of programming, techniques and tools were created to allow the programmer to deal with increasingly greater complexity. Each step of the way, the new approach took the best elements of the previous methods and moved forward.
Earlier to the invention of Object-Oriented Programming, many projects were touching the point where the structured approach no longer worked. Object-oriented methods were created to help programmers overcome these limitations. We can say that Object-Oriented programming is inherited from structured programming. It took the best traits/ideas of structured programming and merged them with several new concepts. The result was a different way of organizing a program. In the most general sense, a program can be organized in one  of the two ways:

  1. around its code 
  2. around its data 

Using only structured programming techniques, programs are typically organized around code. This approach can be thought of as "code acting on data." Let's look at an example, a program, written in C (a structured programming language) is defined by its functions, any of which can manipulate data of any type used by the program. Object-oriented programs work the other way around. They are  organized around data, with the key principle being "data managing access to code." In an object-oriented language, you define the data and the routines that are permitted access that data. Thus, a data type defines exactly the ways in which that data can be manipulated. To support object-oriented programming, all OOP languages have three features in common: encapsulation, polymorphism, and inheritance. Let's explore each.

  • Encapsulation


Encapsulation is the mechanism that combines the data and the functions which manipulate that data, and keeps both safe from tampering and misuse. In an object-oriented language, functions and data may be bound together in such a way that a self-contained black box is created. We can only give input to and receive output from the black-box without knowing what is going inside the box. When functions and data are joined together in this manner, an object is formed. In other words, an object is the device that supports encapsulation. 
Within an object, functions, data or both may be private to that object or public to whole program. Private data of an object is only known to functions of that object and private functions are only accessible within the object. Public members (functions and data) are visible to outside of its objects.

  • Polymorphism

Object-oriented programming languages support polymorphism, which is described by the slogan "one interface, multiple methods." In simple words, polymorphism is the property that allows one interface to control access to a general class of actions
For example, you might have a program that specifies three distinct types of stacks. One stack stores integers, one character and the last floating-point values. You can declare functions with the same names, push() and pop() for all three stacks because polymorphism allows you to. You will create three specific variants of these functions, one for each type of stack, but names of the functions will be the same. The compiler will automatically select the appropriate function based on the data being stored.
Polymorphism helps in reducing the complexity of the program by allowing the same interface to be used to access a general set of procedures. It is the compiler's job to select the specific function as it applies to each state. This selection process is automatic and you, the programmer, do not need to participate. You need only to remember and to utilize the general interface.

  • Inheritance

Inheritance is the process by which one object of a class can acquire the resources/properties of another object of another class. This is important because it promotes the idea of classification and largest data is made manageable by hierarchical classifications.
You can take biological classification as an example. For example is Human part of mammalia class, which in tern is part of subphylum vertebrata, which is under the phylum chordata, and so on. Animals in each class share some or more common traits. Without the use of classifications, each object would have to define explicitly all of its characteristics. However, through the use of classifications it an object defined only those properties which make is unique in its gener or class. It is inheritance which makes it possible to for an object to be a specific instance of a general class. As you will see in your programming journey, inheritance is an important feature of object-oriented programming.

Comments

  1. Very nice post here and thanks for it .I always like and such a super blog of these post.Excellent and very cool idea and great blog of different kinds of the valuable information's.
    aws Training in Bangalore
    python Training in Bangalore
    hadoop Training in Bangalore
    angular js Training in Bangalore
    bigdata analytics Training in Bangalore

    ReplyDelete
  2. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking Best data science courses in hyerabad

    ReplyDelete
  3. Eventually, Google and yahoo came up with innovations that helped in the storage of these with MapReduce and Hadoop respectively. Now that the issue of storing all this information was put out of the way, it was now time for sorting. data science course in india
    With more and more information coming onto the internet everyday, it became harder to go through or find the exact sort of data that was required by an individual. data science course in india

    ReplyDelete
  4. I surely acquiring more difficulties from each surprisingly more little bit of it
    data scientist training and placement

    ReplyDelete
  5. AI Patasala is the most rumoured Python Training in Hyderabad developed to help you advance your career with a massive increase in the latest technology.
    Python Course

    ReplyDelete
  6. I really enjoyed reading this post, big fan. Keep up the good work and please tell me when can you publish more articles or where can I read more on the subject?
    business analytics course in hyderabad

    ReplyDelete

Post a Comment

Popular posts from this blog

Revamping RHC Privacy Poilcy

Privacy Policy Privacy Policy Directorate General Health Services, KP built the Revamping PHC app as a Free app. This SERVICE is provided by Directorate General Health Services, KP at no cost and is intended for use as is. This page is used to inform visitors regarding our policies with the collection, use, and disclosure of Personal Information if anyone decided to use our Service. If you choose to use our Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that we collect is used for providing and improving the Service. We will not use or share your information with anyone except as described in this Privacy Policy.

Privacy policy for Live Text Finder app on playstore

Privacy Policy meancoder built the Live Text Finder app as an Ad Supported app. This SERVICE is provided by meancoder at no cost and is intended for use as is. This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service. If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy. The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which are accessible at Live Text Finder unless otherwise defined in this Privacy Policy. Information Collection and Use For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information. The information that I re