top of page

Factory Design Pattern Coding Exercise

Factory Design Pattern very common pattern used for framework development using Selenium. Automation QAs must know about this pattern if they are going to develop automation framework based on Selenium APIs.

In this post we will share coding exercise that help you understand about pattern in more details.

A Factory Pattern or Factory Method Pattern says that just define an interface or abstract class for creating an object but let the sub classes decide which class to instantiate. In other words, sub classes are responsible to create the instance of the class.

The Factory Method Pattern is also known as Virtual Constructor.

Advantage of Factory Design Pattern

  • Factory Method Pattern allows the sub-classes to choose the type of objects to create.

  • It promotes the loose-coupling by eliminating the need to bind application-specific classes into the code. That means the code interacts solely with the resultant interface or abstract class, so that it will work with any classes that implement that interface or that extends that abstract class.

Usage of Factory Design Pattern

  • When a class doesn't know what sub-classes will be required to create

  • When a class wants that its sub-classes specify the objects to be created.

  • When the parent classes choose the creation of objects to its sub-classes.

Learn Factory Pattern by Example and Video

Here is You tube video that will talk about the project that we going to develop using Factory Pattern

Here is sample problem which need to be solved using Factory Pattern:

Here is project structure which need to be developed. Try to write your own code before downloading the shared code.

Here is Download link to download project source code:


bottom of page