Skip to content

Conversation

@andrej1307
Copy link
Owner

No description provided.

public static TaskManager getDefault() {
return new FileBackedTaskManager();
/* FileBackedTaskManager manager =
FileBackedTaskManager.loadFromFile(new File (".\\data\\tasks.csv"));

Choose a reason for hiding this comment

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

Лишний код лучше убирать

Copy link
Owner Author

Choose a reason for hiding this comment

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

Выполнено.

public class BaseHttpHandler {
protected static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

public void sendText(HttpExchange h, String text, int retCode) throws IOException {

Choose a reason for hiding this comment

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

Классы, которые реализуют интерфейс AutoCloseable можно обрабатывать с помощью try with resources

Copy link
Owner Author

Choose a reason for hiding this comment

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

Добавил обработку исключений.

public class BaseHttpHandler {
protected static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

public void sendText(HttpExchange h, String text, int retCode) throws IOException {

Choose a reason for hiding this comment

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

Более оптимальным вариантом обработки исключений является использование блоков try catch, так как это позволяет сделать более гибкую обработку ошибок(например добавить логи) и избавляет от необходимости пробрасывать исключения по цепочке

Copy link
Owner Author

Choose a reason for hiding this comment

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

Добавил try catch в обработчики http запросов.

*
* @return - объект конвертера gson
*/
public Gson getGson() {

Choose a reason for hiding this comment

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

Gson лучше сделать статическим, это избавит от необходимости каждый раз создавать новый объект

Copy link
Owner Author

Choose a reason for hiding this comment

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

Выполнено.

import java.time.LocalDateTime;
import java.util.Optional;

public class BaseHttpHandler {

Choose a reason for hiding this comment

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

Было бы хорошо структурировать проект, например все классы связанные с обработкой http вынести в отдельную папку

Copy link
Owner Author

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.

3 participants