Object-Oriented Programming

Object-Oriented Programming

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.

Some of the most widely used object-oriented programming languages are Java, C++, and Ruby. Like Python and JavaScript, many languages that are not strictly object-oriented also provide features like classes and objects inspired by object-oriented programming. Simula and Smalltalk are the first languages widely regarded as being object-oriented.

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.

Write clean and secure code with DeepSource

Powerful static analysis that takes 5 minutes to set up and helps you fix code health and security problems on every pull request.