Object-oriented programming is a programming paradigm built on the concept of objects that contain both data and code to modify the data. Object-oriented programming mimics a lot of the real-world attributes of objects.
What are some tenets of object-oriented programming?
- Objects comprise data that define its state and methods that define its behavior. Each object encapsulates these two entities.
- The internal implementation of object methods is invisible to the user. This way objects abstract state changes under a simplified external API.
- Objects are instances of classes. Classes are blueprints to build objects. The class of an object is also its type.
- Classes can inherit both state and behavior from other classes. Based on this notion, objects of the subclass support casting into objects of the parent class.
- This form of casting gives rise to polymorphism. The program can implicitly cast an object of a class to an object of the class's ancestors.