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. I would definitely thank the admin of this blog for sharing this information with us. Waiting for more updates from this blog admin.
    salesforce Training in Bangalore
    uipath Training in Bangalore
    blueprism Training in Bangalore

    ReplyDelete
  2. 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
  3. Awesome Post!!! I really enjoyed reading this article. It's really a nice experience to read your post. Thanks for sharing.
    Data Science Course Training in Bangalore

    ReplyDelete
  4. Really awesome blog!!! I finally found great post here.I really enjoyed reading this article. Thanks for sharing valuable information.
    Data Science Course
    Data Science Course in Marathahalli
    Data Science Course Training in Bangalore

    ReplyDelete
  5. I appreciate your hard work and thanks for sharing. Thanks a lot for explaining practically. Fantastic Post!
    If you want to grow your Business Online, For more information, please visit our website:
    Digital Marketing Company in Ghaziabad
    SMM Services,
    PPC Services,
    SEM Services,
    Best Web Designing Company in India

    ReplyDelete
  6. wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries.
    Data Science Course

    ReplyDelete
  7. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple linear regression

    ReplyDelete

Post a comment

Popular posts from this blog

How Big Data Analytics Can Help You Improve And Grow Your Business?

Big Data Analytics There are certain problems that can only solve through big data. Here we discuss the field big data as "Big Data Analytics". The big data came into the picture we never thought how commodity hardware is used to store and manage the data which is reliable and feasible as compared to the costly sources. Now let us discuss a few examples of how big data analytics is useful nowadays. When you go to websites like Amazon, Youtube, Netflix, and any other websites actually they will provide some field in which recommend some product, videos, movies, and some songs for you. What do you think about how they do it? Basically what kind of data they generated on these kind websites. They make sure to analyze properly. The data generated is not small it is actually big data. Now they analysis these big data they make sure whatever you like and whatever you are the preferences accordingly they generate recommendations for you. If you go to Youtube you have noticed it kn…

How Computers Understand Human Language?

How Computers Understand Human Language? Natural languages are the languages that we speak and understand, containing large diverse vocabulary. Various words have several different meanings, speakers with different accents and all sorts of interesting word play. But for the most part human can roll right through these challenges. The skillful use of language is a major part what makes us human and for this reason the desire for computers that understand or speak human language has been around since they were first conceived. This led to the creation of natural language processing or NLP.
Natural Language Processing is a disciplinary field combining computer science and linguistics. There is an infinite number of ways to arrange words in a sentence. We can't give computers a dictionary of all possible sentences to help them understand what humans are blabbing on about. So, an early and fundamental NLP problem was deconstructing sentences into small pieces which could be more easily…

The Limits of Artificial Intelligence

If you are here, it means that you are familiar with term artificial intelligence. Either you have read about it in school or have seen it in sci-fi movies or somewhere else. Talking about the limitations of AI, let me ask you one simple question first, do you know the definition of AI? You might be thinking to answer me with a yes, yes I know what is artificial intelligence. But what if I tell you that AI is a buzzword and it is almost impossible to properly define. It is this way because the definition of artificial intelligence is moving. People don’t call the things AI that they used to call. For example, a problem that seemed too complex to be solved by human and was solved by AI algorithm is no longer a problem of AI. Playing chess, is one of the examples. It was considered the peek level of artificial intelligence back in previous century. Now it hardly fits the criteria for AI. It is presented to the world as a super power that when given to a computer, it magically starts li…