Tuesday, 11 June 2024

Abstraction

Abstraction is one of principle in object oriented programming ,abstraction showing only necessary details (only method name without implementation) to user/client/developer and hide implementation details, so that user can easily understand what methods are there and how to use it by seeing abstract rather than going through entire implementation, abstract is outer layer of implementation class so user interact with abstract.
usage of abstraction is very high in advanced application like micro services, loosely coupled system , design patterns , solid principles etc.


Real World example of abstract :
if you remember your academic project it may contains around 100 papers in record, for every academic project we will prepare abstract it must be you first paper of project book , so your HOD or project manager look into your abstract understand the key points of project.

What we can understand using abstract

abstract is summary of you entire implementation & methods.
abstract is short info of you lengthy code and features.
user can understand by seeing abstract rather than see  the entire implementation and lengthy lines.
Abstract helps users to remember key points of entire implementation.


Abstraction in C#.Net
We can achieve abstraction using Interface and Abstract class in c#, Interface is example for full abstraction because interface only contains abstract members , Abstract class is example for partial abstraction  it contains Abstract members as well Concrete(Normal class) members Depends on the requirement bot are very useful in development.





Abstraction Definition :

In very simple words Abstraction is concept of hiding complexity of a system and showing only necessary details to its user. So user can access the necessary functionalities easily without thinking of internal complexity of the system. Abstraction mainly focuses on outside view or design of the system.

Real world Example : We can take Keypad mobile as real world example , where you see and use display screen , keypad  and speaker but you can not see how it is internally connected keypad,screen each other using circuits inside mobile, because internal connection programming is not required to user.


Note : Abstraction intention is to decrease complexity by showing essential feature and hide internal implementation , most of the People thinks this is to implement security in application that is not 100% correct  since you can implement security in implementation class if required.

Features of Abstraction in OOP's

Highlighting Essential Features:

Abstraction allows the developer to expose only the relevant attributes and methods of an object that are necessary for the client (user of the object). This makes it easier for the client to interact with the object without being overwhelmed by unnecessary details.

Hiding Implementation Details:

By hiding the complex implementation details and exposing only what is necessary, abstraction simplifies the interaction with the object. This helps in managing complexity and makes the system easier to understand and use.


Reducing Complexity:

Abstraction helps in breaking down complex systems into simpler, high-level components. This makes it easier to manage and maintain the system.


Improving Modularity:

By defining clear and simple interfaces, abstraction promotes modular design. Each module or component can be developed, tested, and understood independently.


Enhancing Maintainability:

With abstraction, changes in the implementation of an object do not affect the code that interacts with it, as long as the interface remains consistent. This improves maintainability and allows for easier updates and modifications.


Encouraging Reusability:

Abstract classes and interfaces define common behaviors that can be reused across different parts of the application or even in different projects. This reduces duplication and promotes code reuse.












Other Definition

Abstraction in OOP is about managing complexity by exposing only the necessary details to the client and hiding the implementation details. While it is not primarily about security, it does contribute to a more secure and robust system by encapsulating the internal workings and reducing the risk of unintended interactions.




Video Reference :

https://www.youtube.com/@ASP4UT

https://www.youtube.com/@ASP4U

No comments:

Post a Comment

Thanks for the contribution, our team will check and reply back if response required.