Swipe to navigate through the chapters of this book
In the first chapters of the book, while implementing a solution to a world problem, data was separated from action. In this chapter, based on the analogy to objects in the real-world, data and action are combined in single representational entities that are called objects. This brings into the scene a new programming paradigm known as “object-oriented programming”. This chapter talks about the ideas and principles that govern object-oriented programming; namely, encapsulation, inheritance and polymorphism. Encapsulation means grouping actions and data together as objects for hiding the internal details of the objects from the outside world, i.e., other objects. Inheritance is the ability to define new objects based on already defined objects. Through inheritance, objects can share actions and data that help the programmer in organizing the solution in a modular and structured manner. Polymorphism, on the other hand, pertains to objects’ behaving differently (either as itself or as the object that it has inherited from) based on context and usage. Finally, how objects are defined in Python is presented and the properties of object-oriented programming are analyzed in Python with illustrative examples.
Please log in to get access to this content
To get access to this content you need the following product:
This is certainly not the only solution to information processing. Our brain ( i.e., a connectionist machine, where every function is handled in the connections of identical self-functioning units), for example, does not make this black and white distinction; you can hardly pinpoint a neuron (nor a group of them) and claim that item stores the age of your grandmother (and nothing else).
To make things more complicated, some authors use the word ‘object’ as a synonym for the ‘instance of a class’.
The example is extremely simplified, and we excluded the amphibian subcategory.
The war god of Mayas.
Another war god of Mayas.
- Objects: Reunion of Data and Action
- Springer Vienna
- Sequence number
- Chapter number
- Chapter 7