Let say we have some Bean (which is POJO)
public class Bean {
}
And we have BeanWrapper which is a wrapper over Bean and represents DTO for the Bean class. Also supports adapter to and from Bean.
public class BeanWrapper {
public Bean toBean() {}
public static BeanWrapper fromBean(Bean bean) {}
}
The question is on the method fromBean
. What should be the correct design pattern for this method - should it be static method?
In other words what is better:
BeanWrapper wrapper = BeanWrapper.fromBean(bean);
Or just non-static method and use it like following:
BeanWrapper wrapper = new BeanWrapper().populateBean(bean);
Which one is better and preferred way over other? And why is it like that?
Aucun commentaire:
Enregistrer un commentaire