Skip to content

Developing#1

Open
Dmi4er4 wants to merge 22 commits into
masterfrom
developing
Open

Developing#1
Dmi4er4 wants to merge 22 commits into
masterfrom
developing

Conversation

@Dmi4er4
Copy link
Copy Markdown
Owner

@Dmi4er4 Dmi4er4 commented Apr 20, 2022

Thanks for checking and have a nice day :)

Copy link
Copy Markdown
Collaborator

@shandomruffle shandomruffle left a comment

Choose a reason for hiding this comment

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

Я честно, как мог, старался душнить, но по существу стилевых замечаний нашлось мало. Зато есть претензии к работоспособности. Глобально никакой паттерн применён не был (хотя, возможно, я его просто не заметил), что, мне кажется, в паре мест помогло допустить баги. А ещё сорсовых файликов в корневой папке как-то много, их бы раскидать по вложенным, что ли — выглядит слишком угрожающе.

По фичам ощущается некоторый недостаток: QSettings не использован, сложность в переводах не изменяется, звуки молчат, об успешном прохождении ничто не уведомляет.

Итого: код очень красивый, жаль, что не работает 🙃

Comment thread translation_exercise.h
void GenerateNextPart() final;
bool CheckAnswer() final;

std::vector<std::pair<QString, QString>> exercises_;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] вектор из пар — очень по-спшницки, потом путаница с first и second
сюда бы специальную мини-структурку

Comment thread tasks_loader.h
static GrammarQuestion GetGrammarFromJson(QJsonObject exercise_obj);
};

#endif // TASKS_LOADER_H_ No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[style] endline

Comment thread translation_exercise.cpp
Comment on lines +18 to +26
layout_->addWidget(task_label_, 1);

layout_->addWidget(sentence_label_, 2);

layout_->addWidget(answer_, 3);

layout_->addWidget(submit_button_, 1);

layout_->addWidget(progress_bar_, 1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[style] пустые строки для логического разделения блоков кода — это прекрасно, но не после каждой же строчки )

Comment thread empty_exercise.h
};
};

#endif // EMPTY_EXERCISE_H_ No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[style] endline

Comment thread README.md
Приложение имеет меню с кнопками выбора типов приложений: ввод перевода или выбор опции.
Сверху располагается меню с опциями выбора уровня сложности, от которого зависят наборы заданий и
опциями звука. Меню сложности также может быть вызвано при помощи комбинации `ctrl+c` Также там расположена информация об оставшихся попытках и начисленных очках.
При привышении заданного максимального количества ошибок выполнение задания прерывается, а при удачном его завершении без ошибок
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[grammar] превышении )

We are going for a walk
My name is Billy
Mr Herrington is reading a newspaper
Bill Gates is mining on my PC
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[minor] такие шикарные файлики, и не используются

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

предположу, что json-ы генерились из этих файликов (было бы интересно увидеть скрипт, который это делает)

Comment thread grammar_exercise.cpp
variant_2_->setText(exercises_[cur_num_question_ - 1].variants[1]);
variant_3_->setText(exercises_[cur_num_question_ - 1].variants[2]);

variant_1_->setChecked(true);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] а правильно ли до ответа делать какой-то вариант предвыбранным?

Comment thread tasks_loader.cpp

std::vector<std::pair<QString, QString>> exercises;

for (const auto &exercise_val : json_exs.value(QString("exercises")).toArray()) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] auto& exercise_val

Comment thread tasks_loader.cpp
exercises.push_back(GetTranslationFromJson(exercise_obj));
}

std::shuffle(exercises.begin(), exercises.end(), std::mt19937(std::random_device()()));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] вот тут шафл здорового человека, а в tasks_loader.cpp:82 шафл курильщика, который устарел и был выведен в C++17

Comment thread tasks_loader.h

class TasksLoader {
public:
static std::vector<std::pair<QString, QString>> LoadTranslation(int cnt,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] раз уж QT, то может и структуры использовать из QT, например QVector и QPair? в них и фичи интересные есть, и с qDebug() удобно отлаживаться

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ну тут мы на лекциях обсуждали, что QVector пользоваться не рекомендуется

Copy link
Copy Markdown
Collaborator

@elizabethfeden elizabethfeden left a comment

Choose a reason for hiding this comment

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

это кусочек ревью, позже добавлю :)

Comment thread .idea/DuoLingo.iml
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

лишние файлики (ниже тоже)

Comment thread central_widget.cpp
Comment on lines +45 to +48
connect(exercise_widget_,
&ExerciseWidget::IncIncorrectSignal,
this,
&CentralWidget::IncIncorrect);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

в целом ChangeToTranslation и ChangeToGrammar почти не отличаются, можно одну функцию сделать с аргументом о том, что именно создавать. Также и два сигнала (ChangeToTranslationSignal и ChangeToGrammarSignal) можно не создавать, а кидать только один с параметром "на что поменять"

Comment thread central_widget.cpp
layout_->addWidget(exercise_widget_, 1);

connect(exercise_widget_,
&ExerciseWidget::IncScoreSignal,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[style] я бы постаралась стилистически сохранить нейминг сигналов qt, т. е. здесь было бы ScoreIncreased, ну и все другие сигналы тоже

Comment thread central_widget.cpp
}

void CentralWidget::IncScore() {
emit(IncScoreSignal());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[style] обычно после emit не ставят скобочки (как после return)

Comment thread central_widget.cpp
Comment on lines +35 to +37
layout_->removeWidget(exercise_widget_);
delete exercise_widget_;
exercise_widget_ = new GrammarExercise(this, difficulty_level_);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

непонятно, зачем создавать новый виджет каждый раз, учитывая, что у виджетов можно менять сложность, не пересоздавая их. можно же хранить по экземпляру GrammarExercise и TranslationExercise в полях класса, или даже в QStackedWidget, просто переключая в нем текущий выбор

Comment thread choice_widget.cpp
Comment on lines +85 to +95
void ChoiceWidget::ChangeToTranslation() {
translation_button_->setStyleSheet("background-color: #8b008b");
grammar_button_->setStyleSheet("background-color: #50c878");
emit(ChangeToTranslationSignal());
}

void ChoiceWidget::ChangeToGrammar() {
translation_button_->setStyleSheet("background-color: #50c878");
grammar_button_->setStyleSheet("background-color: #8b008b");
emit(ChangeToGrammarSignal());
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] вот эти две функции тоже можно было заменить одной, принимающей, на что меняем

Comment thread choice_widget.cpp
emit(ChangeToGrammarSignal());
}

void ChoiceWidget::MyResizeEvent(QResizeEvent* event) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

а чем qt-шный resizeevent тут не подошел?

Comment thread difficulty_dialog.cpp
Comment on lines +9 to +15
auto* easy_button(new QRadioButton(tr("Easy")));
auto* medium_button(new QRadioButton(tr("Medium")));
auto* hard_button(new QRadioButton(tr("Hard")));

difficulty_buttons_.append(easy_button);
difficulty_buttons_.append(medium_button);
difficulty_buttons_.append(hard_button);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
auto* easy_button(new QRadioButton(tr("Easy")));
auto* medium_button(new QRadioButton(tr("Medium")));
auto* hard_button(new QRadioButton(tr("Hard")));
difficulty_buttons_.append(easy_button);
difficulty_buttons_.append(medium_button);
difficulty_buttons_.append(hard_button);
for (const auto& name : {"Easy", "Medium", "Hard"}) {
difficulty_buttons_.append(new QRadioButton(name))
}

точно, кстати, им при создании не нужно родителя указывать?

Comment thread empty_exercise.h

#include "exercise_widget.h"

class EmptyExercise : public ExerciseWidget {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

architecture-wise, для вещей типа "сгенерить новое упражнение" и "проверить ответ" стоило создать класс, не связанный с qt. нужно разделять логку и ее отображение

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

зачем вообще, кстати, emptyexercise нужен, непонятно. выглядит, будто и без него можно обойтись

Comment thread exercise_widget.cpp
}

void ExerciseWidget::RestartFail() {
auto* wrong_dialog(new QDialog(this));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

здесь можно было и стандартным диалогом QMessageBox::information обойтись, там названия кнопок можно менять

Copy link
Copy Markdown
Collaborator

@elizabethfeden elizabethfeden left a comment

Choose a reason for hiding this comment

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

В целом да, ощущается незаконченность/неотполированность, видно, что не успел добавить фичи и поправить баги.
Архитектура местами кривоватая, хотя с большего норм.
Местами сделано не совсем по тз, предполагалось, например, что главная страница и упражнения не показываются одновременно, а так непонятно, ставить ли баллы за пункты типа "должна быть возможность вернуться к главной странице".
Но все равно молодец конечно, видно, что семестр Qt был не зря, и можешь сделать что-то больше, чем пустое приложение с кнопкой "выход" :)

Антон, ревью отличное, всем довольна.

We are going for a walk
My name is Billy
Mr Herrington is reading a newspaper
Bill Gates is mining on my PC
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

предположу, что json-ы генерились из этих файликов (было бы интересно увидеть скрипт, который это делает)

Comment thread grammar_question.h
@@ -0,0 +1,14 @@
#ifndef GRAMMAR_QUESTION_H_
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] такие структурки имеет смысл объявлять там же, где они используются, в этом случае в grammar_exercise.h

Comment thread central_widget.h
void IncScore();
void IncIncorrect();

void MyResizeEvent(QResizeEvent* event);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

а зачем "my"?

Comment thread menu.cpp
label_->setText(str);
}
void Menu::DecTries() {
tries_--;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

в целом проверка на отрицательность не помешала бы

Comment thread menu.h
int score_ = 0;
int tries_ = 2;
QLabel* label_;
MusicClass* music_class_;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

меня здесь снова архитектурно смущает, что меню почему-то отвечает за музыку. но здесь скорее проблема снова в том, что смешивается несмешиваемое. класс, который отвечает за настройки музыки и класс, который отвечает за проигрывание музыки - разные.

Comment thread tasks_loader.cpp
Comment on lines +10 to +26
switch (level) {
case 0: {
file_path = ":/exercises/translation_easy.json";
break;
}
case 1: {
file_path = ":/exercises/translation_medium.json";
break;
}
case 2: {
file_path = ":/exercises/translation_hard.json";
break;
}
default: {
break;
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

или на мапку index/enum -> filename

Comment thread tasks_loader.cpp
Comment on lines +43 to +44
exercises.resize(cnt);
exercises.shrink_to_fit();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

зачем?

Comment thread tasks_loader.cpp
return exercises;
}

std::vector<GrammarQuestion> TasksLoader::LoadGrammar(int cnt, int level) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[style] много дублирования кода с LoadTranslation

Comment thread grammar_question.h
QString question;
QVector<QString> variants;
QString answer;
QString tip;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

подсказка не используется(

Comment thread translation_exercise.cpp
void TranslationExercise::GenerateNextPart() {
progress_bar_->setValue(cur_num_question_);
sentence_label_->setText(exercises_[cur_num_question_++].first);
answer_->setText(tr(""));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

зачем тут tr :) вообще, странно эта штука используется, не на всех строках она есть, да и текст сомневаюсь, что планируется переводить

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