Learn-Object_Oriented_programming-with-us
Learn By Topic:
Class-objects
Inheritance
Polymorphism
Encapsulation
Abstraction
Click here to toggle b/w normal and focus mode: FOCUS MODE
What is OOP's?
Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic.
OPs refers to languages that uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
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.
Benefits of OOP
- OOP models complex things as reproducible, simple structures
- Reusable, OOP objects can be used across programs
- Allows for class-specific behavior through polymorphism
- Easier to debug, classes often contain all applicable information to them
- Secure, protects information through encapsulation
Building blocks of OOP
- Classes
- Objects
- Methods
- Attributes
Four Principles of OOP
The four pillars of object oriented programming are:
- Inheritance: child classes inherit data and behaviors from parent class
- Encapsulation: containing information in an object, exposing only selected information
- Abstraction: only exposing high level public methods for accessing an object
- Polymorphism: many methods can do the same task