Skip to content

Conversation

@SolalPirelli
Copy link
Contributor

Which comments are useful? Which are not? Should there be more?

Open the "Files changed" tab to start

@@ -0,0 +1,18 @@
import java.util.Scanner;

public final class ConsoleView implements View {
Copy link
Contributor Author

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
Copy link
Contributor Author

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.*;
Copy link
Contributor Author

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()) {
Copy link
Contributor Author

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))
Copy link
Contributor Author

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());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")) {
Copy link
Contributor Author

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"));
Copy link
Contributor Author

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<>();
Copy link
Contributor Author

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")));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants