where do you use overloading in framework code example

Example 1: where do you use overloading in framework

Method overloading is providing 
two separate methods in a class 
with the same name but different arguments,
while the method return type 
may or may not be different, which
allows us to reuse the same method name.
In my framework==
I use implicit wait in Selenium. Implicit wait
is an example of overloading. In Implicit wait
we use different time stamps such as SECONDS, MINUTES, HOURS etc.,
A class having multiple methods with
same name but different parameters 
is called Method Overloading

Example 2: how to use abstraction in your framework

I used in defining a common super class while writing POM layer of the framework
We usually create an abstract class named
BasePage to have all common members for every page written
in this class like getPageTitle().
Then each Page class (HomePage, LoginPage, DashboardPage
etc.) inherit from BasePage.
Sometimes one may need to change the behavior of methods
implemented in superclass. So, subclass has freedom to
override that method where we use polymorphism.
This is how we use Abstract class in real projects

Example 3: where do you use overriding in framework

Set set = new HashSet<>();
List list = new ArrayList<>();
set.add(4);  ==> HashSet overrides add() method from Collection Interface
list.add(8); ==> ArrayList overrides add() method from Collection Interface

WebDriver driver1 = new ChromeDriver();
driver1.get("xxxxxx"); ChromeDriver overrides get/findElement/etc.
                                      methods from WebDriver Interface.

WebDriver driver2 = new FirefoxDriver();
driver2.get("xxxxxx"); FirefoxDriver overrides 
get/findElement/etc. methods from WebDriver Interface.

Tags:

Misc Example