Design Patterns Java - Factory Method Php

1) What have we got at the beginning?

Let's imagine that we have at the beginning objects of "Product" type and we have in application two different implementations: "Product1" and "Product2"


public interface Product
{
}

public class Product1 implements Product
{
}

public class Product2 implements Product
{
}




Let's also imagine that we have some abstract object "Registry" when we can register "Products"


import java.util.List;

public class Registry
{
    private List<Product> products;

    public void addProduct(Product product)
    {
        products.add(product);
    }
}




Now imagine how looks client, let's see imagine that we always create Products together with adding them to Registry. This occurs many time.


public class Client
{
    private static Registry registry = new Registry();

    public static void main(String[] args)
    {
        Product product = new Product1();
        registry.addProduct(product);
    }
}




2) Can we improve this ?

Of course we should extract this code (of creating and adding to registry) as it is done in many places.
So let's see to step 2.