-
Notifications
You must be signed in to change notification settings - Fork 0
kotlin project Archive #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
| val archives = mutableListOf<Archive>() | ||
| var isRunnig = true | ||
| while (isRunnig) { | ||
| val mainMenuOptions = listOf("Создать архив", "Выбрать архив", "Выход") |
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.
Это лучше вынести за цикл while, т.к. сейчас на каждую итерацию цикла будет создан новый список, а если вынести на строчку выше, то список будет создан один на всю программу, таким образом будет меньше операций с памятью
| if (selectedArchive != null) { | ||
| var isRunningNoteMenu = true | ||
| while (isRunningNoteMenu) { | ||
| val noteMenuOption = listOf("Создать заметку", "Выбрать заметку", "Выход") |
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.
Здесь аналогично создание списка можно вынести на строчку выше, чтобы было меньше операций с памятью
| import modules.Archive | ||
| import utils.readNonBlankString | ||
|
|
||
| fun createArchive(archives: MutableList<Archive>) { |
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.
Лучше функции делать чистыми(https://ru.wikipedia.org/wiki/%D0%A7%D0%B8%D1%81%D1%82%D0%BE%D1%82%D0%B0_%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0%B8), чтобы их было проще переиспользовать и покрывать тестами. Чтобы данную функцию сделать чистой, можно убрать аргумент функции и сделать ей возвращаемое значение - объект класса Archive, чтобы метод добавления созданного архива в список была на вызывающей стороне
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.
В этом файле очень хорошие утилитные функции, молодец. Файл правда суперский, но нейминг ему лучше подбирать более говорящий, например InputUtils
Студент 23 когорты
Данилов Аркадий