vendredi 2 octobre 2015

Logic inside BuilderPattern

Recently I came across with a builder pattern that intrigued me.

So, I have an EntityBuilder which builds an Entity, but it doesn't return the entity. Here is the method signature:

public void build();

Instead, inside the build() method, it delivers the new object created, the Entity, to a CacheImplementation instance to store it. Note: the CacheImpl is injected in the builder's constructor.

public void build(){
    //create new entity
    cacheImplementation.add(entity);
}

Does this sounds like best practice?

Aucun commentaire:

Enregistrer un commentaire