I received from following comments on my code :
It is a procedural design
, and there is temporal coupling
between lines in method names()
.
It is quite apparent that what names()
is doing—creating a list of names.
In order to avoid duplication, there is a supplementary procedure, append()
, which converts an item to lowercase and adds it to the list.
class Foo {
public List<String> names() {
List<String> list = new LinkedList();
Foo.append(list, "a");
Foo.append(list, "b");
return list;
}
private static void append(
List<String> list, String item) {
list.add(item.toLowerCase());
}
}
Can any one give me some pointers like how can I improve this design ?
Aucun commentaire:
Enregistrer un commentaire