What is the best practice to use Factory Method pattern in Java8.
For example, which of two is better?
interface UserFactory {
default String makeDialog() {
return "Hello\n" + createUser().sayHi();
}
User createUser();
}
or
abstract class UserFactory {
String makeDialog() {
return "Hello\n" + createUser().sayHi();
}
abstract User createUser();
}
Aucun commentaire:
Enregistrer un commentaire