Skip to content

Conversation

@Binary-Cat-01
Copy link

No description provided.

carRepository.rewrite();
}

public void displayCars() {
Copy link
Owner

Choose a reason for hiding this comment

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

этот сервис работает с машинами. Он должен отвечать за работу с машинами. А за вывод отвечать не должен. Завтра будем писать в файл/БД или отдавать результаты по Сети. Что тогда делать с этим методом?

return carRepository.getCars()[foundCarIndex];
}

public void update() {
Copy link
Owner

Choose a reason for hiding this comment

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

Мутная история. Выглядит, будто это не ответственность конкретно этого сервиса


public class UnableParsingException extends RuntimeException {
public UnableParsingException(String message, String value) {
super("%s %s".formatted(message, value));
Copy link
Owner

Choose a reason for hiding this comment

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

Просто ParsingException будет достаточно

Copy link
Owner

Choose a reason for hiding this comment

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

И достаточно странное формирование сообещния. Я же могу что угодно передать параметрами, из-за чего на выходе будет бессмысленная строка. В данном случае логичнее сформировать строку при создании эксепшна и передать одним параметром

private static final String ELEMENT_SEPARATOR = "\n";
private static final String FIELD_SEPARATOR = " ";

public String toLine(Car car) {
Copy link
Owner

Choose a reason for hiding this comment

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

это не ответственность парсера - ведь ты делаешь ровно противоположное парсингу действие:)

this.cars = cars;
}

public void append(Car car) {
Copy link
Owner

Choose a reason for hiding this comment

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

лучше таки add()

public Car find(Car car) {
int foundCarIndex = indexOf(car);

if (foundCarIndex == -1) {
Copy link
Owner

Choose a reason for hiding this comment

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

можно объединить с return ниже, описав как тернарное выражение

.formatted(years, months, days, hours, minutes, seconds);
}
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn 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