Here is the psudeocode:
if (parttimeEmployee) {
if (country == USA) {
}
if (country == UK {
}
}
if (fullTimeEmployee) {
if (country == USA) {
}
if (country == UK) {
}
}
Now, partTime and fullTime employees can be subclassed from 'Employee' interface.
But we have another if-else repeated/replicated inside each of them for 'Country'
Which design-pattern can we use to completely replace such nested-conditions ?
Aucun commentaire:
Enregistrer un commentaire