-
Notifications
You must be signed in to change notification settings - Fork 0
Exercise 2: Reviewing a review #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,18 @@ | |||
| import java.util.Scanner; | |||
|
|
|||
| public final class ConsoleView implements View { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be at least some basic Javadoc on public all classes/methods
| private final Scanner scanner = new Scanner(System.in); | ||
|
|
||
| public void show(String text) { | ||
| // Prints `text` on the console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not very useful?
| @@ -0,0 +1,32 @@ | |||
| import java.io.*; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO wildcard imports are bad
|
|
||
| public List<String> names() { | ||
| var result = new ArrayList<String>(); | ||
| for (var entry : root.entrySet()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use .stream() instead for consistency with the method below?
| public Map<String, String> translatedNames(String language) { | ||
| return root.entrySet().stream() | ||
| .map(e -> e.getValue().getAsJsonObject()) | ||
| .filter(p -> p.has(language)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do some entries not have a translation? Should we document this?
|
|
||
| var parts = command.split(" "); | ||
| if (parts[0].equals("searcch")) { | ||
| showList(model.names().stream().filter(n -> n.contains(parts[0])).toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| showList(model.names().stream().filter(n -> n.contains(parts[0])).toList()); | |
| showList(model.names().stream().filter(n -> n.contains(parts[1])).toList()); |
| } | ||
|
|
||
| public void onInput(String command) { | ||
| if (command.equals("list")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should support more input languages than English
| void namesAreLoaded() { | ||
| var model = new LocalDatabaseModel(); | ||
| var names = model.names(); | ||
| assertThat(names, hasItems("Sextans Dwarf Spheroidal Galaxy")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test the order of names?
|
|
||
| private static final class FakeView implements View { | ||
| public List<String> inputs = new ArrayList<>(); | ||
| public List<String> outputs = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Public fields are bad
| } | ||
|
|
||
| private void showList(List<String> list) { | ||
| view.show(list.stream().map(s -> "- " + s).collect(Collectors.joining("\n"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| view.show(list.stream().map(s -> "- " + s).collect(Collectors.joining("\n"))); | |
| view.show(list.stream().map(s -> "* " + s).collect(Collectors.joining("\n"))); |
I like bullet points more
Which comments are useful? Which are not? Should there be more?
Open the "Files changed" tab to start