I have a object named Person
.
I want to fill this object with multiple equal conditions .
this is my example code :
class Person {
String name ;
String family ;
/* Getter and Setter */
}
class Scratch {
public Person getPerson() {
Person p = null ;
if (p == null) {
/* Fill object with method A*/
}
if (p == null) {
/* Fill object with method B*/
}
if (p == null) {
/* Fill object with method C*/
}
/*
* Maybe i have more conditions ...
* */
return p ;
}
}
I searching for better solution .
have any design pattern for this subject ?
Aucun commentaire:
Enregistrer un commentaire