Abstraction by Parameterization and Specification in Java
Abstraction by Parameterization and specification both are important methods in Java. We do this in hope of simplifying our analysis by separating attributes and details implementation for user requirements by showing the essential part to the user and hiding certain details for various purposes like security, maintenance, etc.
- Abstractions help us in many ways like an easy way to arrange code.
- It also helps in decomposing big steps into smaller steps.
- It is useful for suppressing details and simplifying interaction.
- Abstraction plays an important role in improving the maintenance part of the project.
Basically, abstraction is a method to provide simplicity by hiding all the mechanisms behind them. For example when someone calls you so you see on your screen that XYZ is calling you with a green icon to receive and a red icon with a reject option and some messaging option but, what you do not see is all the backend mechanisms that how someone is calling you how by tapping on-screen icon you can receive/reject or text someone how it’s going to connect to caller all the things. This way abstraction makes things simple.
Fee :1000 Hello! Ashish your roll_no is :12345
Methods of Abstraction :
- Abstraction by Parameterization.
- Abstraction by Specification.
Abstraction by Parameterization :
It abstracts from the identity of the data by replacing them with parameters.
x % 2 = 0
It describes a computation that when we divide a number x to 2 then the remainder is equal to zero which we use for finding that given number x is even or not.
x : int(x % 2 == 0)(y)
It is identical in meaning to
y % 2==0
In more familiar notation, we might denote the previous expression by the following expression given below.
Abstraction by Specification:
It abstracts from the implementation details (how the module is implemented) to the behavior users can depend on (what the module does). It isolates modules from one another’s implementations.
It allows us to abstract from the computation described by the body of a procedure to the end that procedure was designed to accomplish. We do this by associating with each other procedure a specification of its intended effect and then considering the meaning of a procedure call to be based on this specification rather than on the procedure’s body.
In this program, you will see how you can write the logic for a user like if the user wants only input any number and just to know whether a given number is odd or even the logic of the program is given below to check the even and odd for any user input number.
Input : 11 Output : Odd Input : 52 Output : Even
Enter an Integer number: 78 Entered number is even
Please Login to comment...