C# Basic Object-Oriented Principles:
Objectives
- What is Basic Object-Oriented Principles(OOP)?
- Encapsulation
- Abstraction
- Inheritance
- Polymorphism
What is Basic Object-Oriented Principles(OOP)?
Object-Oriented Programming (OOP) is a programming paradigm that is built around objects, which carry data (attributes) and code (methods). In the context of software designing and development, the basic principles of OOP aim to deliver modular and flexible as well as maintainable software.
Encapsulation:
Encapsulation implies putting together data or attributes and methods or functions operating on them in one unit called class.
This hides object’s inner state so that it can only be accessed using certain defined procedures known as methods.
It helps in achieving data hiding, abstraction, and modularity.
Abstraction:
Abstraction process is simplifying complicated systems by ignoring unnecessary details while exposing crucial aspects involved.
Instead of looking at how an object does something; we focus on what it does?
By managing complexity, reuse ability is promoted since we can use these objects in other programs even when they are updated for future maintenance purposes.
Inheritance:
A mechanism where a subclass acquires the members (fields, methods) from its superclass is called inheritance.
This allows objects to share common characteristics such as properties or behaviors among themselves through hierarchical classification that groups them according to their similarities.
It enables the derived class to add or change the behavior of base class thereby promoting reusability of code within program modules.
Inheritance promotes code organization, enhances code readability, and reduces redundancy.
Polymorphism:
Polymorphism is the ability of different types of objects to be treated like objects of a common base class.
It allows objects to have multiple forms or behaviors depending on their context or the message they respond to.
Polymorphism encourages dynamic method binding, method overriding and method overloading which increases flexibility and extensibility.
The principles encapsulation, abstraction, inheritance, polymorphism are what underpin object-oriented programming.
They create a basis for constructing modular, reusable and maintainable software systems that encourage code organization, modularity and flexibility. When these principles are correctly understood and applied it can result into better software design and development practices.