Recently, I came across a build pattern that intrigued me.
So, I have an EntityBuilder that builds an Entity but does not return an object. Here is the method signature:
public void build();
Instead, inside the build() method, it delivers the new object created by Entity to the CacheImplementation instance to save it. Note: CacheImpl is injected into the constructor constructor.
public void build(){
Does that sound like best practice?
Edit 0 later
public interface EntityBuilder { void setProperty0(PropertyObject propertyObject0); void setProperty1(PropertyObject propertyObject1); void setProperty2(PropertyObject propertyObject2);
The builder is used as follows:
public class EntityProcessor{ private EntityBuilderFactory entityBuilderFactory;
Note: the cacheImpl instance simply stores the objects in List<> , which access every N seconds.
source share