Make Selenium Easy

REST Assured Tutorial 5 – Abstraction – Hide The Implementation

Last updated on December 4th, 2019 at 01:10 pm

As a part of End to End REST Assured Tutorial , in this post We will learn about Abstraction in Java.

If you are thinking why this topic is necessary , do not worry. I will connect all dots in upcoming posts.

Abstraction is one of the pillar in Object Oriented Programming. Java is an Object Oriented Programming language so it follows abstraction concept is as well. You must have gone through Abstraction concept and you find a common sentence as below:-

Hiding the implementation and showing the essential feature to user is called Abstraction. Abstraction can be achieved using Abstract class and interface.”

When you start learning about Abstract class and interface and try to relate above Abstraction concept with it, you lose the path. When we say hiding the implementation is an abstraction then a method is also an example of abstraction. You create a method with all logic in it to perform a task and make it public so that other can simply use it without bothering about how method works internally. “Showing all essential details to outside world” is also possible using access specifiers like public , private , protected and default. What is special in Abstract class and Interface which allow us to achieve Abstraction? I hope I am making some sense.

I can define Abstraction as “Hiding the implementation” which could be done in multiple ways.

When we say Abstract class and Interface are ways to achieve abstraction, it means that “Perform a specific task and I don’t really bother how you do it“. Suppose I need to get the population of each district in India. I have a token which says that I need population details. Now a representative of each district will come to me and collect token. It is all representatives responsibility to provide me population detail of their districts. I really don’t bother how they will arrange the details. Process of performing tasks may be different for each district. This is actually meant by Abstraction.

Now relate this understanding with the concepts of Interface and Abstract class. Hopefully you will be able to understand. The best example will be WebDriver interface in Selenium. WebDriver has a contract of methods which is supposed to perform a specific task. Browser specific classes which implement WebDriver has responsibility to perform those tasks in their ways. Chrome browser does not worry about how Firefox browser is performing a tasks. WebDriver also has nothing to worry about implementation done by various browser. This is Abstraction.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyLearning

You can find all Selenium related post here.
You can find all API manual and automation related posts here.
You can find frequently asked Java Programs here.

Table of Contents

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

1 thought on “REST Assured Tutorial 5 – Abstraction – Hide The Implementation

  1. very well explained the concept of Abstraction ,, but one doubt is

    if the concept is i dont care how you implement it.. then they can use public private etc whataver they want ?

    Why those keywords explicitly mentioned ? We don’t use them to achieve abstraction generally

    we use abstract class and interface instead of those access specifiers.

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

REST Assured Tutorial 5 – Abstraction – Hide The Implementation

by Amod Mahajan time to read: 2 min
1
%d bloggers like this: