Skip to content
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

Quizlet - CQFDKS #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RetroRider02
Copy link

No description provided.

{
if (!questionDAO.QuestionIsExist(question))
{
if (question.AnswerIndex >= 0 && question.AnswerIndex <= 4)
Copy link
Contributor

Choose a reason for hiding this comment

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

A 4 egy magic konstans

}
else
{
AnsiConsole.Write(new Markup($"[bold red]\n Error: The good answer index is lower then 0 or higher then 4!\n\n[/]"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Spectre.Console 👍

{
public class QuestionController
{
private IQuestionDAO questionDAO = new QuestionDAO();
Copy link
Contributor

Choose a reason for hiding this comment

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

Dependency Inversion?

{
public class ScoreController
{
private IScoreDAO scoreDAO = new ScoreDAO();
Copy link
Contributor

Choose a reason for hiding this comment

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

Szintén lehetne dependency inversion

{
try
{
var count = scoreDAO.GetScores().Where(x => x.Email == score.Email && x.Category == score.Category).Count();
Copy link
Contributor

Choose a reason for hiding this comment

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

Dupla linq szűrés ugyan arra az adatra? FirstOrDefault() Null-t ad vissza ha nincs és akkor a try-catch se kell, meg a Count() alapú számolás. A (Count > 0) amúgy is helyettesíthető lenne egy Any() hívással.


public void EvaluateAnswer(List<Question> questions, List<string> answeredQuestions)
{
for (int i = 0; i < answeredQuestions.Count(); i++)
Copy link
Contributor

Choose a reason for hiding this comment

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

A Count() minden esetben egy foreach-el a háttérben számol. Az olyan kollekciók, mint a Lista rendelkezik egy Count property-vel, amit érdemes lenne használni.

subText.DisplayText("Main Menu");
var choice1 = AnsiConsole.Prompt(new SelectionPrompt<string>().Title(" Choose a functionality!").PageSize(6).AddChoices(functionalities));

switch (choice1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ez a blokk ismétlődik egy párszor. Erre egy metódus jó lenne.

public static IdGenerator generator = new IdGenerator(0);

public static int GenerateID()
{
Copy link
Contributor

Choose a reason for hiding this comment

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

A CreateId() a IdGen-ben long-ot ad vissza, így ez túcsordul mint állat, főleg hogy ez idő alapon generál ahogy néztem a forráskódját. Vagyis az ID amit ezzel generálsz nem a legjobb megoldás. Ennél akár egy Random.Shared.Next() is jobb lenne. De felmerül a kérdés: A szimpla növekményes ID miért nem jó?


namespace Quizlet.Utilities
{
public class MainTitle
Copy link
Contributor

Choose a reason for hiding this comment

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

Ez egy értelmetlen osztály, A FigletText-et akár magában is létrehozhatná string-ből, akkor több értelme lenne.

{
private Rule Text { get; set; }

public SubTitle(Rule text)
Copy link
Contributor

Choose a reason for hiding this comment

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

Szintén, mint a FigletText-es osztály

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