Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Object-Oriented Programming (OOP)

Intro

A programming paradigm based on the concept of "objects," which contain data (attributes) & behavior (methods). OOP helps in designing software that is modular, reusable, scalable.

Key Principles

1. Encapsulation

Encapsulation is the bundling of data (attributes) & methods that operate on that data within a single unit (object). It restricts direct access to some components, which helps in maintaining data integrity & security.

  • Example: A class hides its internal state & only allows controlled access through public methods.

2. Abstraction

Abstraction is the process of hiding unnecessary details & exposing only the essential features of an object.

  • Example: A car's driver interacts with the steering wheel & pedals without needing to understand the engine's internal mechanics.

3. Inheritance

Inheritance allows one class (child or subclass) to acquire the properties & behaviors of another class (parent or superclass). This promotes code reusability & hierarchical relationships.

  • Example: A "Vehicle" class may have a subclass "Car" that inherits its properties like speed & fuel capacity but also has additional features like air conditioning.

4. Polymorphism

Polymorphism allows the same operation to be performed in different ways based on the object that calls it. This makes code more flexible & scalable.

  • Example: A function called "draw()" could be used for different shapes like circles, rectangles, triangles, each having its own implementation of "draw()".

Benefits

  • Modularity: Code is organized into objects & classes, making it easier to manage.
  • Reusability: Classes and objects can be reused in different parts of the application or even in different projects.
  • Scalability: OOP makes it easier to scale applications as they grow in complexity.
  • Maintainability: Changes can be made to specific parts of the code without affecting the entire system.
  • Security: Encapsulation helps protect data from unintended modifications.

About

Object Orinted Programming

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages