-
Notifications
You must be signed in to change notification settings - Fork 23
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
base: main
Are you sure you want to change the base?
Quizlet - CQFDKS #15
Conversation
{ | ||
if (!questionDAO.QuestionIsExist(question)) | ||
{ | ||
if (question.AnswerIndex >= 0 && question.AnswerIndex <= 4) |
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.
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[/]")); |
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.
Spectre.Console 👍
{ | ||
public class QuestionController | ||
{ | ||
private IQuestionDAO questionDAO = new QuestionDAO(); |
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.
Dependency Inversion?
{ | ||
public class ScoreController | ||
{ | ||
private IScoreDAO scoreDAO = new ScoreDAO(); |
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.
Szintén lehetne dependency inversion
{ | ||
try | ||
{ | ||
var count = scoreDAO.GetScores().Where(x => x.Email == score.Email && x.Category == score.Category).Count(); |
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.
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++) |
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.
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) |
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.
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() | ||
{ |
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.
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 |
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.
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) |
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.
Szintén, mint a FigletText-es osztály
No description provided.