Tuesday, 17 February 2015

Command design pattern Implementation

Command Design Pattern

Hibernate                                                                                              Core Java


Question : - What is Command Design Pattern?
This pattern falls under behavioural pattern. All the information required to invoke a method is encapsulated in this pattern. One of the most popular framework “Struts” uses this design pattern. This pattern helps us to build our command objects into a “ready to run” state and also help to pass those objects to an "invoker" class which makes a callback to the execute() method of each class at the exact/appropriate time. This invoker object does not know about the logic which a command object contains, it only knows that it has to call an execute() method when an event occurs.

As per GOF :-“Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.”

Question : - When to use Command design pattern?
     1.  Performing action to process the complete workflow of request and response.
  1. Thread Pools – A thread pool class is having a method which adds a work item to an internal queue of tasks and these tasks will wait to be completed. It maintains a pool of threads that execute commands from the queue. The items available in the queue are known as command objects.
  2. For implementing Graphical User Interface menu items and buttons.
  3. In networking for playing online games – It might be require to send complete command objects across the network to be executed on multiple nodes.
  4. This pattern is also useful for wizards, progress bars, parallel processing e.t.c.
 Advantage of using command design pattern : -
  • This pattern helps to decouple the invoker and receiver implementation. Receiver knows how to process the request. 
  • Client creats a concrete command object and specifies to its receiver. 
  • An invoker object stores the concrete command object. Then the invoker issues a request by calling execute() method on the command object. 
  • The concrete command  object invoke operations on its receiver to carry out the request. 
  • Command implementation selects the method to invoke on receiver object, and it works as a bridge between receiver and action methods.
  • This(Command) pattern is easily extensible, we can add multiple action methods in receivers and create new Command implementations without changing the client code.
  • The disadvantage or drawback with this pattern is that the code gets huge and it is confusing with high number of action methods and their associations.
  • Fundamental terms of Command design pattern is Client, Invoker and Receiver.


In Jdk
Runnable interface (java.lang.Runnable) and Swing Action (javax.swing.Action) uses command design pattern.

In Live example 
we can think about the order placed online in any shopping site, where it executes for appropriate actions for calling chosen payment gateway for money deduction and confirming the client order with selected items. 

In the below example we will see how to implement this design pattern in Java programming.

Command .java

package com.gaurav.designpattern.command;

/**
 * @author gaurav
 * 
 */
public interface Command {

public void execute();

}

RemoteControl.java


package com.gaurav.designpattern.command;

/**
 * @author gaurav
 * 
 */
public class RemoteControl {

private Command putOn;
private Command putOff;

public RemoteControl(Command on, Command off) {
putOn = on;
putOff = off;
}

public void startOn() {
putOn.execute();
}

public void startOff() {
putOff.execute();
}
}


AirCondition.java

package com.gaurav.designpattern.command;

/**
 * @author gaurav
 * 
 */
public class AirCondition {
public void startCooling() {
System.out.println("Air condition is started cooling.");
}

public void stopCooling() {
System.out.println("Air condition is off now.");
}
}

LedTelevision.java

package com.gaurav.designpattern.command;

/**
 * @author gaurav
 * 
 */
public class LedTelevision {
public void turnOn() {
System.out.println("TV is on now.");
}

public void turnOff() {
System.out.println("TV is off.");
}
}


StartCoolingCommand.java


package com.gaurav.designpattern.command;

/**
 * @author gaurav
 * 
 */
public class StartCoolingCommand implements Command {
private AirCondition airCondition;

public StartCoolingCommand(AirCondition ac) {
airCondition = ac;
}

@Override
public void execute() {
airCondition.startCooling();
}

}


StopCoolingCommand.java


package com.gaurav.designpattern.command;

/**
 * @author gaurav
 * 
 */
public class StopCoolingCommand implements Command {
private AirCondition airCondition;

public StopCoolingCommand(AirCondition ac) {
airCondition = ac;
}

@Override
public void execute() {
airCondition.stopCooling();
}
}


TurnOnCommand.java


package com.gaurav.designpattern.command;

/**
 * @author gaurav
 * 
 */
public class TurnOnCommand implements Command {
private LedTelevision ledTelevision;

public TurnOnCommand(LedTelevision led) {
ledTelevision = led;
}

@Override
public void execute() {
ledTelevision.turnOn();
}

}


TurnOffCommand.java


package com.gaurav.designpattern.command;

/**
 * @author gaurav
 * 
 */
public class TurnOffCommand implements Command {
private LedTelevision ledTelevision;

public TurnOffCommand(LedTelevision led) {
ledTelevision = led;
}

@Override
public void execute() {
ledTelevision.turnOff();
}
}


CommandDesignPatternDemo.java


package com.gaurav.designpattern.command;

/**
 * @author gaurav
 * 
 */
public class CommandDesignPatternDemo {
public static void main(String args[]) {
AirCondition airCondition = new AirCondition();

StartCoolingCommand startCC = new StartCoolingCommand(airCondition);
StopCoolingCommand stopCC = new StopCoolingCommand(airCondition);

RemoteControl acRemoteControl = new RemoteControl(startCC, stopCC);
acRemoteControl.startOn();
acRemoteControl.startOff();

LedTelevision ledTV = new LedTelevision();
TurnOnCommand turnOnCommand = new TurnOnCommand(ledTV);
TurnOffCommand turnOffCommand = new TurnOffCommand(ledTV);

RemoteControl tvRemoteControl = new RemoteControl(turnOnCommand,
turnOffCommand);
tvRemoteControl.startOn();
tvRemoteControl.startOff();
}
}


Result:-

Air condition is started cooling
Air condition is off now
TV is on now.
TV is off.

Execution Flow:-

Friday, 6 February 2015

Chain of Responsibility Implementation

Chain of Responsibility Design Pattern

Hibernate                                                                                              Core Java


Question :- What is Chain of Responsibility Design Pattern?
Answer : - 


As per GOF : -"Gives more than one object an opportunity to handle a request by linking receiving objects together."

Question: - When to use Chain of Responsibility design pattern?

1. This design pattern helps to reduced coupling between the sender of a request and the receiver – the sender and receiver are not aware about each other means sender will not know which object in the chain will serve its request. In a chain of objects, the responsibility of deciding who to serve the request is left to the objects participating in the chains.

2. When more than one object may handle a request and the actual handler object is not know in advance or when requests follow a model - that is, some requests can be handled where they are generated while others must be forwarded to another object to be handled.

3. Dynamically, the chain of handlers can be modified.

Disadvantage: -
There is a possibility that a request could fall off the end of the chain without being handled.

Examples in JAVA API :

In JDK, we know about try-catch block, where we can mention multiple catch blocks. When exception occurs in try block then every catch block which are a kind of processor tries to process that exception, if catch clock is not able to handle that exception then it is forwarding to next catch block in chainalize manner. If last catch block is also not able to handle the occurred exception then the exception is thrown outside of the chain to the calling program.

javax.servlet.Filter -> doFilter()
The doFilter method of the Filter class is called by the container each time when a request or response is passed through the chain. The FilterChain object passed in to this method allows the Filter to pass on the request and response to the next entity in the chain for serving the request and providing the response to the intended recipient.

In Live example, we can think about the customer support of any organization which is based on chaining system or the hierarchy of a purchase department for approval of payment amount based on designation. 

Below we will implement the purchase department hierarchy example using chain of responsibility design pattern. In this example we will see that how request is processing in the chain and after process how we will get response after filtration.

AuthTypeRequest .java
package com.gaurav.designpattern.chainofresponsibility;

public class AuthTypeRequest {

private double amount;
private String expenditureType;

public AuthTypeRequest(String expenditure, double amount) {
this.expenditureType = expenditure;
this.amount = amount;
}

public double getAmount() {
return amount;
}

public void setAmount(double amt) {
amount = amt;
}

public String getExpenditureType() {
return expenditureType;
}

public void setExpenditureType(String expenditureType) {
this.expenditureType = expenditureType;
}

}

AuthorizationCapacity.java

package com.gaurav.designpattern.chainofresponsibility;

abstract class AuthorizationCapacity {

    protected final double limit = 50000;
    protected AuthorizationCapacity authCapacity;

    public void setOrganizationalHierarchy(AuthorizationCapacity authorizationCapacity){
        this.authCapacity = authorizationCapacity;
    }

    abstract public void serveRequest(AuthTypeRequest request);

}


HRManager.java

package com.gaurav.designpattern.chainofresponsibility;

public class HRManager extends AuthorizationCapacity {
    private final double EXPENDITURE_LIMIT = 10 * limit;

    public void serveRequest(AuthTypeRequest authTypeRequest ) {
        if( authTypeRequest.getAmount() < EXPENDITURE_LIMIT ){
            System.out.println("HR MANAGER EXPENDITURE LIMIT FOR APPROVAL IS : "+EXPENDITURE_LIMIT);
            System.out.println("AS SPENT AMOUNT "+authTypeRequest.getAmount()+" FALLS UNDER HIS EXPENDITURE LIMIT,SO HE CAN APPROVE THIS.");
        }
        else
           if( authCapacity != null)
          authCapacity.serveRequest(authTypeRequest);
  }
}

Director.java

package com.gaurav.designpattern.chainofresponsibility;

public class Director extends AuthorizationCapacity {
    private final double EXPENDITURE_LIMIT = 30 * limit;

    public void serveRequest(AuthTypeRequest authTypeRequest ) {
        if( authTypeRequest.getAmount() < EXPENDITURE_LIMIT ){
        System.out.println("DIRECTOR EXPENDITURE LIMIT FOR APPROVAL IS : "+EXPENDITURE_LIMIT);
       
        System.out.println("AS SPENT AMOUNT "+authTypeRequest.getAmount()+" FALLS UNDER HIS EXPENDITURE LIMIT,SO HE CAN APPROVE THIS.");
            }
        else
           if( authCapacity != null)
          authCapacity.serveRequest(authTypeRequest);
  }
}

VicePresident.java

package com.gaurav.designpattern.chainofresponsibility;

public class VicePresident extends AuthorizationCapacity {
    private final double EXPENDITURE_LIMIT = 50 * limit;

    public void serveRequest(AuthTypeRequest authTypeRequest ) {
        if( authTypeRequest.getAmount() < EXPENDITURE_LIMIT ){
       
        System.out.println("DIRECTOR EXPENDITURE LIMIT FOR APPROVAL IS : "+EXPENDITURE_LIMIT);
       
        System.out.println("AS SPENT AMOUNT "+authTypeRequest.getAmount()+" FALLS UNDER HIS EXPENDITURE LIMIT, SO HE CAN APPROVE THIS.");
        }
        else
           if( authCapacity != null)
          authCapacity.serveRequest(authTypeRequest);
  }
}

CEO.java

package com.gaurav.designpattern.chainofresponsibility;

public class CEO extends AuthorizationCapacity {
    private final double EXPENDITURE_LIMIT = 70 * limit;

    public void serveRequest(AuthTypeRequest authTypeRequest ) {
    if(authTypeRequest.getAmount()> EXPENDITURE_LIMIT)
    {
    System.out.println("AS PER POLICY THE EXPENDITURE LIMIT OF CEO IS : "+EXPENDITURE_LIMIT);
    System.out.println("AS SPENT AMOUNT "+authTypeRequest.getAmount()+" IS ABOUVE EXPENDITURE LIMIT OF CEO. SO HE NEEDS SHAREHOLDERS APPROVAL TO APPROVE THIS AMOUNT.");
    }
    if( authTypeRequest.getAmount() < EXPENDITURE_LIMIT ){
            System.out.println("A CEO IS THE OWNER OF THE COMPANY, \nSO HE IS HAVING POWER TO APPROVE COMPLETE AMOUNT \nBUT HE ALSO NEED TO TAKE OPINION FROM OTHER DIRECTORS SO THE APPROVAL AMOUNT IS i.e. INR : "+ EXPENDITURE_LIMIT);
            System.out.println("AS SPENT AMOUNT FALLS UNDER HIS EXPENDITURE LIMIT,SO HE CAN APPROVE THIS.");
        }
        else
           if( authCapacity != null)
          authCapacity.serveRequest(authTypeRequest);
  }
}

ChainofResponsibilityDesignPatternDemo.java

package com.gaurav.designpattern.chainofresponsibility;

import java.util.Scanner;

public class ChainofResponsibilityDesignPatternDemo {
private static Scanner enteredVal;

public static void main(String[] args) throws Exception{
HRManager hrmanager = new HRManager();
       Director director = new Director();
       VicePresident vp = new VicePresident();
       CEO ceo = new CEO();
      
       hrmanager.setOrganizationalHierarchy(director);
       director.setOrganizationalHierarchy(vp);
       vp.setOrganizationalHierarchy(ceo);
       
       enteredVal = new Scanner(System.in);
       
       System.out.println("Enter the expenditure type : ");
       String expenditureType = enteredVal.nextLine(); 
       
       System.out.println("Enter the amount spent for the work : ");
       double amount = enteredVal.nextDouble();
       
           System.out.println("Check inside the organization who is having limit to approve for expenditure : ");
           AuthTypeRequest authTypeRequest = new AuthTypeRequest(expenditureType, amount);
           hrmanager.serveRequest(authTypeRequest);

 }
}


Result:

Scenario 1 :

Enter the expenditure type : 
Stationary
Enter the amount spent for the work : 
50000
Check inside the organization who is having limit to approve for expenditure : 
HR MANAGER EXPENDITURE LIMIT FOR APPROVAL IS : 500000.0
AS SPENT AMOUNT 50000.0 FALLS UNDER HIS EXPENDITURE LIMIT,SO HE CAN APPROVE THIS.

Scenario 2 :

Enter the expenditure type : 
Resource Hiring
Enter the amount spent for the work : 
1000000
Check inside the organization who is having limit to approve for expenditure : 
DIRECTOR EXPENDITURE LIMIT FOR APPROVAL IS : 1500000.0
AS SPENT AMOUNT 1000000.0 FALLS UNDER HIS EXPENDITURE LIMIT,SO HE CAN APPROVE THIS.

Scenario 3 :

Enter the expenditure type : 
Campus renovation
Enter the amount spent for the work : 
2000000
Check inside the organization who is having limit to approve for expenditure : 
VICE PRESIDENT EXPENDITURE LIMIT FOR APPROVAL IS : 2500000.0
AS SPENT AMOUNT 2000000.0 FALLS UNDER HIS EXPENDITURE LIMIT, SO HE CAN APPROVE THIS.

Scenario 4 :

Enter the expenditure type : 
Company Extension
Enter the amount spent for the work : 
3000000
Check inside the organization who is having limit to approve for expenditure : 
A CEO IS THE OWNER OF THE COMPANY, 
SO HE IS HAVING POWER TO APPROVE COMPLETE AMOUNT 
BUT HE ALSO NEED TO TAKE OPINION FROM OTHER DIRECTORS SO THE APPROVAL AMOUNT IS i.e. INR : 3500000.0
AS SPENT AMOUNT FALLS UNDER HIS EXPENDITURE LIMIT,SO HE CAN APPROVE THIS.

Scenario 5 :

Enter the expenditure type : 
Share Listing
Enter the amount spent for the work : 
4000000
Check inside the organization who is having limit to approve for expenditure : 
AS PER POLICY THE EXPENDITURE LIMIT OF CEO IS : 3500000.0
AS SPENT AMOUNT 4000000.0 IS ABOUVE EXPENDITURE LIMIT OF CEO. SO HE NEEDS SHAREHOLDERS APPROVAL TO APPROVE THIS AMOUNT.


Thursday, 15 January 2015

Proxy Design Pattern Implementation

Proxy Design Pattern

Hibernate                                                                                              Core Java


Question :- What is Proxy Design Pattern

As per GOF :-"Provide a surrogate or placeholder for another object to control access over it."

This design pattern helps us to create a wrapper over real object. It helps to control in accessing of the real object with the help of proxy object. 

  • This(Proxy design) pattern works on the principal of exposing Java object through a proxy instead of real object.

  • For securing an actual object this pattern can be used. Service provider does not want actual class to be visible to any client Instead It would be shared as per Client contract agreement . Service provider may agree to share only a part of Service with it's client and for that It may expose a different contract in the form of interface in java.

  • Client is not aware of actual object and through Proxy only relevant behavior of actual object will be exposed to client.

  • This pattern will help for lazily loading of an object. Data will be loaded only when it is actually required in an operation till then only proxy to real object will be kept as reference. So as to invoke desired method later and retrieve the actual instance.


The main intention of a proxy is to control access to the target object rather then to enhance the functionality of the target object.There are ways that proxies can provide access control which includes : -
  • Synchronization
  • Authentication
  • Remote Access
  • Lazy instantiation

Now considering a example where we can execute few command to open a specified application. Here the twist is opening any normal application is fine but opening a specific application should be controlled and we should provide access to those users who is having all type of permissions. Here a proxy class can be used to provide controlled access to those programs.

AppExecutor.java

package com.gaurav.designpattern.proxy;
/**
 * @author Gaurav
 * 
 */

public interface AppExecutor {
public boolean openApplication(String appName) throws Exception;
}


AppExecutorImpl.java

package com.gaurav.designpattern.proxy;
/**
 * @author Gaurav
 * 
 */

import java.io.IOException;

public class AppExecutorImpl implements AppExecutor{

@Override
public boolean openApplication(String appName) throws IOException {
boolean successFlag = false;
try{
Runtime.getRuntime().exec(appName);
successFlag = true;
}catch(IOException ioe){
System.out.println("Error message is : "+ioe.getMessage());
}
return successFlag;
}
}


AppExecutorProxy.java

package com.gaurav.designpattern.proxy;
/**
 * @author Gaurav
 * 
 */

public class AppExecutorProxy implements AppExecutor{
private boolean IsManagerLevelPermission = false;
    private AppExecutor appExecutor;
     
    public AppExecutorProxy(String userName, String password){
        if("Gaurav".equals(userName) && "Kumar#2013".equals(password)) 
        IsManagerLevelPermission = true;
        appExecutor = new AppExecutorImpl();
    }
     
    @Override
    public boolean openApplication(String appName) throws Exception {
        boolean success = false;
    if(IsManagerLevelPermission){
            appExecutor.openApplication(appName);
            success = true;
        }else{
            if(appName.trim().startsWith("mspaint")){
                throw new Exception("mspaint application is only available to managers.");
            }else{
                appExecutor.openApplication(appName);
                success = true;
            }
        }
    return success;
    }
}


ProxyDesignPatternDemo.java

package com.gaurav.designpattern.proxy;
/**
 * @author Gaurav
 * 
 */

public class ProxyDesignPatternDemo {
public static void main(String[] args){
        AppExecutor executor = new AppExecutorProxy("Gaurav", "welcome321");
        try {
           executor.openApplication("calc");
           executor.openApplication("notepad");
           boolean isExecuted = executor.openApplication("mspaint");
           System.out.println("Is mspaint app is executed : "+isExecuted);
        } catch (Exception e) {
            System.out.println("Error occurred is : "+e.getMessage());
        }
         
    }
}


Result:-

Error occurred is : mspaint application is only available to managers.

Note:- Here we are passing the wrong password which is not matching with the specified password.

Spring MVC                                           Spring Transaction                                        Web-Services

Monday, 3 November 2014

Flyweight Design Pattern Implementation

Flyweight Design Pattern

Flyweight design pattern falls under Structural design pattern. This will help to make instances of classes on the fly to improve performance efficiently. This helps to make the instance of the similar class sharing some common state to be reused as much as possible to boost the performance and minimize the memory consumption. The idea behind this pattern is to reduce the load of memory by sharing objects.

The best example is String API in java. In Java, String objects are managed as flyweight objects. Lets see the below example where we can find that what benefits are there to use this design pattern:-

package com.gaurav.designpattern.flyweight;

public class StringPoolTest {
public static void main(String args[]) {
String name = "Gaurav";
String nameVar = "Gaurav";
if (name == nameVar) {
System.out
.println("Both objects are referring to the same memory location in order to minimize memory");
}
}
}

Result:-

Both objects are referring to the same memory location in order to minimize memory


*****Now Consider on the example where we need to create different shapes like circle, rectangle and square in different colors at run-time. Instead of creating multiple instances of same shape type and color, if it has been already created reuse the same. We will see the example below.

Shape.java

package com.gaurav.designpattern.flyweight;
/**
 * @author Gaurav
 * 
 */
public interface Shape {
public String getColor();
public void draw();
}

Circle.java

package com.gaurav.designpattern.flyweight;
/**
 * @author Gaurav
 * 
 */
public class Circle implements Shape{

private String color;
public Circle(String color){
this.color = color;
}
@Override
public String getColor() {
return color;
}

@Override
public void draw() {
System.out.println("Drawing Cirle having color : "+color);
}
}

Rectangle.java

package com.gaurav.designpattern.flyweight;
/**
 * @author Gaurav
 * 
 */
public class Rectangle implements Shape{

private String color;
public Rectangle(String color){
this.color = color;
}
@Override
public String getColor() {
return color;
}

@Override
public void draw() {
System.out.println("Drawing Rectangle having color : "+color);
}

}

Square.java

package com.gaurav.designpattern.flyweight;
/**
 * @author Gaurav
 * 
 */
public class Square implements Shape{

private String color;
public Square(String color){
this.color = color;
}
@Override
public String getColor() {
return color;
}

@Override
public void draw() {
System.out.println("Drawing Square having color : "+color);
}
}

ShapeType.java

package com.gaurav.designpattern.flyweight;
/**
 * @author Gaurav
 * 
 */
public enum ShapeType {
SQUARE,
RECTANGLE,
CIRCLE
}

ShapeFactory.java

package com.gaurav.designpattern.flyweight;
/**
 * @author Gaurav
 * 
 */
import java.util.ArrayList;
import java.util.List;

public class ShapeFactory {

private static ShapeFactory instance;
private List<Shape> shapePool;

private ShapeFactory() {
shapePool = new ArrayList<Shape>(0);
}

public Shape getShape(ShapeType shapeType, String color) {
Shape shape = null;
switch (shapeType) {
case SQUARE:
shape = getShapeUsingPool(shapeType, color);
if (shape == null) {
shape = new Square(color);
shapePool.add(shape);
}
break;

case RECTANGLE:
shape = getShapeUsingPool(shapeType, color);
if (shape == null) {
shape = new Rectangle(color);
shapePool.add(shape);
}
break;
case CIRCLE:
shape = getShapeUsingPool(shapeType, color);
if (shape == null) {
shape = new Circle(color);
shapePool.add(shape);
}
break;
}
return shape;
}

private Shape getShapeUsingPool(ShapeType shapeType, String color) {
Shape shapeP = null;
for (Shape shape : shapePool) {

if (shapeType.equals(ShapeType.SQUARE)) {
if (shape instanceof Square && color.equals(shape.getColor())) {
shapeP = shape;
break;
}
}

if (shapeType.equals(ShapeType.RECTANGLE)) {
if (shape instanceof Rectangle && color.equals(shape.getColor())) {
shapeP = shape;
break;
}
}

if (shapeType.equals(ShapeType.CIRCLE)) {
if (shape instanceof Circle && color.equals(shape.getColor())) {
shapeP = shape;
break;
}
}

}

return shapeP;
}

public int getOverallObjectCreated() {
return shapePool.size();
}
public static ShapeFactory getInstance() {
if (instance == null) {
instance = new ShapeFactory();
}
return instance;
}
}

FlyweightdesignPatternDemo.java

package com.gaurav.designpattern.flyweight;
/**
 * @author Gaurav
 * 
 */
import java.util.Random;

public class FlyweightdesignPatternDemo {
public static void main(String args[]) {
ShapeFactory shapeFactory = ShapeFactory.getInstance();
ShapeType shapeTypes[] = { ShapeType.CIRCLE, ShapeType.RECTANGLE,
ShapeType.SQUARE };
String colors[] = { "RED", "MAGENTA", "PINK", "BLUE", "BLACK", "YELLOW" };

Random random = new Random();
for (int i = 0; i < 15; i++) {
ShapeType shapeType = shapeTypes[random.nextInt(shapeTypes.length)];
String color = colors[random.nextInt(colors.length)];
Shape shape = shapeFactory.getShape(shapeType, color);
shape.draw();
}
System.out
.println("Numbers of overall Objects created after object pool are : "
+ shapeFactory.getOverallObjectCreated());
}
}

Results:

Drawing Cirle having color : BLACK
Drawing Rectangle having color : BLUE
Drawing Cirle having color : BLUE
Drawing Rectangle having color : PINK
Drawing Rectangle having color : RED
Drawing Cirle having color : BLACK
Drawing Square having color : RED
Drawing Cirle having color : MAGENTA
Drawing Square having color : YELLOW
Drawing Rectangle having color : MAGENTA
Drawing Square having color : RED
Drawing Square having color : BLACK
Drawing Cirle having color : BLACK
Drawing Rectangle having color : RED
Drawing Rectangle having color : MAGENTA
Numbers of overall Objects created after object pool are : 10