While exploring the wonders of Object-Oriented Programming (OOP) in Python, I was in search of a straightforward and easy-to-catch definition of this fascinating programming approach. In contrast to procedural programming that maintains a strict separation between data (variables) and procedures (functions), OOP allows the definition of new types (referred to as classes in Python) that encapsulate both methods and properties into a single “Object”. Since Objects provide an interface with ” the rest of the world”, they are modular, reusable and customizable chunks of code. Here below is the best definiton I have found so far to describe OOP:
“OOP is a programming approach where OBJECTS (entities, items or things) are defined with METHODS (functions, actions or events) and PROPERTIES (values, attributes or characteristics), resulting in more readable, more reusable code.” Lets say you’re writing a program where you need to keep track of multiple cars. Each car has different characteristics like mileage, color, and top speed, but lucky for us they all can perform some common actions like braking, accelerating, and turning. Instead of writing code separately for each car we could create a class called ‘Car’ that will be the blueprint for each particular car”.