Pass IEnumerable as an argument of method and repository pattern












2












$begingroup$


I've seen tutorials of Unit Testing and I've never seen that IEnumerable<T> used as an argument of method. All authors use Repository pattern and Service layers to interact with data, that is, authors of tutorials get data in Service layer by Repository and there is no need to pass collections between the methods of Service layer.



However, I've written a simple quiz game which imitates Repository pattern and when I started writing unit test methods, then I realized that many of my methods has arguments type of IEnumerable<T>.



This is a simple quiz game where user can give simple answers to simple questions . For example, quiz asks question, then program will remember the answer of player and in the end program will calculate the overall score of the player answers. e.g. "How many continents are there on the Earth?", then quiz shows 4 possible answers, and then quiz remembers answers.



The whole code of my quiz game looks like this:



Model classes:



public class Answer
{
public Answer(int idAnswer, int idQuestion, string content)
{
IdAnswer = idAnswer;
IdQuestion = idQuestion;
Content = content;
}

public int IdAnswer { get; }
public string Content { get; }
public int IdQuestion { get; }
}

public class Question
{
public Question(int idQuestion, string content)
{
IdQuestion = idQuestion;
Content = content;
}

public int IdQuestion { get; }
public string Content { get; }
}

public class QuestionAnswer
{
public QuestionAnswer(int idQuestion, int idAnswer)
{
IdQuestion = idQuestion;
IdAnswer = idAnswer;
}
public int IdQuestion { get; set; }
public int IdAnswer { get; set; }
}


Program class:



static void Main(string args)
{
IQuestionRepository questionService = Factory.CreateInstance<QuestionRepository>();
var questions = questionService.GetQuestions();

IAnswerRepository answerService = Factory.CreateInstance<AnswerRepository>();
var possibleAnswers = answerService.GetPossibleAnswers(questions);
var playerAnswers = GetPlayerAnswers(questions, possibleAnswers);
IQuestionAnswerRepository questionAnswerRepository =
Factory.CreateInstance<QuestionAnswerRepository>();
var correctAnswers = questionAnswerRepository.GetCorrectAnswers(questions);

ICountPlayerScoreBySum playerScores =
Factory.CreateInstance<CountPlayerScoreBySumService>();
var playerScore = playerScores.CountPlayerScoreBySum(playerAnswers, correctAnswers);

var winScoreString = ConfigurationManager.AppSettings.Get("WinScore");
int winScore = 0;
int.TryParse(winScoreString, out winScore);

Console.WriteLine( playerScore == winScore ?
$"Wow! You are a winner! Your score is {playerScore}"
: $"Try again! It is just the lesson to win! Your score is {playerScore}");
}


The method GetPlayerAnswers of Program class:



private static IEnumerable<Answer> GetPlayerAnswers(IEnumerable<Question> questions, 
IEnumerable<Answer> possibleAnswers)
{
List<string> allowedAnswers = new List<string>()
{
Constants.Constants.Answers.A,
Constants.Constants.Answers.B,
Constants.Constants.Answers.C,
Constants.Constants.Answers.D,
};

var playerAnswers = new List<Answer>();

foreach (var question in questions)
{
var possibleAnswersViewModel = possibleAnswers
.Where(a => a.IdQuestion == question.IdQuestion)
.OrderBy(a=>a.IdAnswer)
.Select((a, i) => new PlayerAnswerViewModel {
Content = $"{ IntToLetters(i)}. {a.Content}",
IdAnswer = a.IdAnswer,
IdQuestion = a.IdQuestion,
PlayerKey = IntToLetters(i)
});

AskQuestion(question, possibleAnswersViewModel);

while (true)
{
var playerKey = Console.ReadKey().KeyChar.ToString().ToUpper();
Console.WriteLine();
if (!allowedAnswers.Contains(playerKey))
{
AskQuestion(question, possibleAnswersViewModel, true);
}
else
{
var answer = possibleAnswersViewModel
.Where(a => a.PlayerKey == playerKey)
.FirstOrDefault();
if(answer != null)
playerAnswers.Add(new Answer(
answer.IdAnswer,
question.IdQuestion,
playerKey));
break;
}
}
}

return playerAnswers;
}


The methods AskQuestion and IntToLetters of Program class:



private static void AskQuestion(Question question, 
IEnumerable<PlayerAnswerViewModel> possibleAnswers,
bool showPossibleKeys = false)
{
if (showPossibleKeys)
{
Console.WriteLine();
Console.WriteLine("Possible keys are A, B, C or D");
}

Console.WriteLine(question.Content);
possibleAnswers
.ToList()
.ForEach(a => Console.WriteLine(a.Content));
}

public static string IntToLetters(int value)
{
string result = string.Empty;
result = (char)('A' + value % 26) + result;
return result;
}


Repositories:



public interface IAnswerRepository
{
IEnumerable<Answer> GetPossibleAnswers(IEnumerable<Question> questions);
}

interface IQuestionAnswerRepository
{
IEnumerable<QuestionAnswer> GetCorrectAnswers(IEnumerable<Question> questions);
}

interface IQuestionRepository
{
IEnumerable<Question> GetQuestions();
}


And implementation of repositories. AnswerRepository:



class AnswerRepository : IAnswerRepository
{
public IEnumerable<Answer> GetPossibleAnswers(IEnumerable<Question> questions)
{
return new List<Answer>() {
new Answer(11, 3, "Sequoia"), new Answer(12, 3, "Berch"), new Answer(13, 3, "Lindens"), new Answer(14, 3, "Alder"),
new Answer(1, 1, "1"), new Answer(2, 1, "2"), new Answer(3, 1, "5"), new Answer(4, 1, "6"),
new Answer(7, 2, "More than 1"), new Answer(8, 2, "More than 2"), new Answer(9, 2, "More than 5"), new Answer(10, 2, "More than 6"),
new Answer(15, 4, "yes, I do!"), new Answer(16, 4, "Sure!"), new Answer(17, 4, "Exactly"), new Answer(18, 4, "Yeap!"),
new Answer(19, 5, "yes, I do!"), new Answer(20, 5, "Sure!"), new Answer(21, 5, "Exactly"), new Answer(22, 5, "Yeap!"),
new Answer(23, 6, "yes, I do!"), new Answer(24, 6, "Sure!"), new Answer(25, 6, "Exactly"), new Answer(26, 6, "Yeap!"),
new Answer(27, 7, "yes, I do!"), new Answer(28, 7, "Sure!"), new Answer(29, 7, "Exactly"), new Answer(30, 7, "Yeap!")
}.Where(qa => questions
.Select(q => q.IdQuestion)
.Contains(qa.IdQuestion)
);
}
}


QuestionAnswerRepository. Imitation of getting correct answers of questions from Database:



public class QuestionAnswerRepository : IQuestionAnswerRepository
{
public IEnumerable<QuestionAnswer> GetCorrectAnswers(IEnumerable<Question> questions)
{
return new List<QuestionAnswer>() {
new QuestionAnswer(1, 1),
new QuestionAnswer(2, 2),
new QuestionAnswer(3, 3),
new QuestionAnswer(4, 4),
new QuestionAnswer(5, 1),
new QuestionAnswer(6, 1),
new QuestionAnswer(7, 1),
new QuestionAnswer(8, 1),
new QuestionAnswer(9, 1),
new QuestionAnswer(10, 1)
}
.Where(qa => questions
.Select(q=>q.IdQuestion)
.Contains(qa.IdQuestion)
);
}
}


QuestionRepository:



public class QuestionRepository : IQuestionRepository
{
public IEnumerable<Question> GetQuestions()
{
return new List<Question>() {
new Question(1, "How many are there contintents?"),
new Question(2, "How many are there colours?"),
new Question(3, "What is the tallest tree?"),
new Question(4, "Do you like dolphins?"),
};
}
}


and CountPlayerScoreBySumService:



public class CountPlayerScoreBySumService : ICountPlayerScoreBySum
{
public int CountPlayerScoreBySum(IEnumerable<Answer> playerAnswers,
IEnumerable<QuestionAnswer> correctAnswers)
{
var sum = 0;
foreach (var userAnswer in playerAnswers)
{
var correctAnswer = correctAnswers
.Where(a => a.IdQuestion == userAnswer.IdQuestion)
.FirstOrDefault();

if (correctAnswer != null) {
if (userAnswer.IdAnswer == correctAnswer.IdAnswer)
sum += 1;
}
}

return sum;
}
}


and Factory service:



public class Factory
{
public static T CreateInstance<T>() where T : new()
{
return new T();
}
}


However, my signatures of methods looks like this. Many methods have arguments type of array:



private IEnumerable<Answer> GetPlayerAnswers(IEnumerable<Question> questions, 
IEnumerable<Answer> possibleAnswers)
{
...
}


Is it okay? Is it a code smell to pass collections as arguments of a method? Or my quiz game is not properly designed? If yes, please be very kind, to advice me how design of an application can be improved.



In addition, I've pushed all my code of Quiz game code into GitHub.










share|improve this question











$endgroup$








  • 1




    $begingroup$
    Could you edit your question please and explain what the quiz is about? We need this for context. Otherwise if you're not interested in a general review you should try Software Engineering.
    $endgroup$
    – t3chb0t
    2 hours ago






  • 1




    $begingroup$
    @t3chb0t Thank you for your attention, I've edited my question and explained what the quiz about.
    $endgroup$
    – StepUp
    2 hours ago
















2












$begingroup$


I've seen tutorials of Unit Testing and I've never seen that IEnumerable<T> used as an argument of method. All authors use Repository pattern and Service layers to interact with data, that is, authors of tutorials get data in Service layer by Repository and there is no need to pass collections between the methods of Service layer.



However, I've written a simple quiz game which imitates Repository pattern and when I started writing unit test methods, then I realized that many of my methods has arguments type of IEnumerable<T>.



This is a simple quiz game where user can give simple answers to simple questions . For example, quiz asks question, then program will remember the answer of player and in the end program will calculate the overall score of the player answers. e.g. "How many continents are there on the Earth?", then quiz shows 4 possible answers, and then quiz remembers answers.



The whole code of my quiz game looks like this:



Model classes:



public class Answer
{
public Answer(int idAnswer, int idQuestion, string content)
{
IdAnswer = idAnswer;
IdQuestion = idQuestion;
Content = content;
}

public int IdAnswer { get; }
public string Content { get; }
public int IdQuestion { get; }
}

public class Question
{
public Question(int idQuestion, string content)
{
IdQuestion = idQuestion;
Content = content;
}

public int IdQuestion { get; }
public string Content { get; }
}

public class QuestionAnswer
{
public QuestionAnswer(int idQuestion, int idAnswer)
{
IdQuestion = idQuestion;
IdAnswer = idAnswer;
}
public int IdQuestion { get; set; }
public int IdAnswer { get; set; }
}


Program class:



static void Main(string args)
{
IQuestionRepository questionService = Factory.CreateInstance<QuestionRepository>();
var questions = questionService.GetQuestions();

IAnswerRepository answerService = Factory.CreateInstance<AnswerRepository>();
var possibleAnswers = answerService.GetPossibleAnswers(questions);
var playerAnswers = GetPlayerAnswers(questions, possibleAnswers);
IQuestionAnswerRepository questionAnswerRepository =
Factory.CreateInstance<QuestionAnswerRepository>();
var correctAnswers = questionAnswerRepository.GetCorrectAnswers(questions);

ICountPlayerScoreBySum playerScores =
Factory.CreateInstance<CountPlayerScoreBySumService>();
var playerScore = playerScores.CountPlayerScoreBySum(playerAnswers, correctAnswers);

var winScoreString = ConfigurationManager.AppSettings.Get("WinScore");
int winScore = 0;
int.TryParse(winScoreString, out winScore);

Console.WriteLine( playerScore == winScore ?
$"Wow! You are a winner! Your score is {playerScore}"
: $"Try again! It is just the lesson to win! Your score is {playerScore}");
}


The method GetPlayerAnswers of Program class:



private static IEnumerable<Answer> GetPlayerAnswers(IEnumerable<Question> questions, 
IEnumerable<Answer> possibleAnswers)
{
List<string> allowedAnswers = new List<string>()
{
Constants.Constants.Answers.A,
Constants.Constants.Answers.B,
Constants.Constants.Answers.C,
Constants.Constants.Answers.D,
};

var playerAnswers = new List<Answer>();

foreach (var question in questions)
{
var possibleAnswersViewModel = possibleAnswers
.Where(a => a.IdQuestion == question.IdQuestion)
.OrderBy(a=>a.IdAnswer)
.Select((a, i) => new PlayerAnswerViewModel {
Content = $"{ IntToLetters(i)}. {a.Content}",
IdAnswer = a.IdAnswer,
IdQuestion = a.IdQuestion,
PlayerKey = IntToLetters(i)
});

AskQuestion(question, possibleAnswersViewModel);

while (true)
{
var playerKey = Console.ReadKey().KeyChar.ToString().ToUpper();
Console.WriteLine();
if (!allowedAnswers.Contains(playerKey))
{
AskQuestion(question, possibleAnswersViewModel, true);
}
else
{
var answer = possibleAnswersViewModel
.Where(a => a.PlayerKey == playerKey)
.FirstOrDefault();
if(answer != null)
playerAnswers.Add(new Answer(
answer.IdAnswer,
question.IdQuestion,
playerKey));
break;
}
}
}

return playerAnswers;
}


The methods AskQuestion and IntToLetters of Program class:



private static void AskQuestion(Question question, 
IEnumerable<PlayerAnswerViewModel> possibleAnswers,
bool showPossibleKeys = false)
{
if (showPossibleKeys)
{
Console.WriteLine();
Console.WriteLine("Possible keys are A, B, C or D");
}

Console.WriteLine(question.Content);
possibleAnswers
.ToList()
.ForEach(a => Console.WriteLine(a.Content));
}

public static string IntToLetters(int value)
{
string result = string.Empty;
result = (char)('A' + value % 26) + result;
return result;
}


Repositories:



public interface IAnswerRepository
{
IEnumerable<Answer> GetPossibleAnswers(IEnumerable<Question> questions);
}

interface IQuestionAnswerRepository
{
IEnumerable<QuestionAnswer> GetCorrectAnswers(IEnumerable<Question> questions);
}

interface IQuestionRepository
{
IEnumerable<Question> GetQuestions();
}


And implementation of repositories. AnswerRepository:



class AnswerRepository : IAnswerRepository
{
public IEnumerable<Answer> GetPossibleAnswers(IEnumerable<Question> questions)
{
return new List<Answer>() {
new Answer(11, 3, "Sequoia"), new Answer(12, 3, "Berch"), new Answer(13, 3, "Lindens"), new Answer(14, 3, "Alder"),
new Answer(1, 1, "1"), new Answer(2, 1, "2"), new Answer(3, 1, "5"), new Answer(4, 1, "6"),
new Answer(7, 2, "More than 1"), new Answer(8, 2, "More than 2"), new Answer(9, 2, "More than 5"), new Answer(10, 2, "More than 6"),
new Answer(15, 4, "yes, I do!"), new Answer(16, 4, "Sure!"), new Answer(17, 4, "Exactly"), new Answer(18, 4, "Yeap!"),
new Answer(19, 5, "yes, I do!"), new Answer(20, 5, "Sure!"), new Answer(21, 5, "Exactly"), new Answer(22, 5, "Yeap!"),
new Answer(23, 6, "yes, I do!"), new Answer(24, 6, "Sure!"), new Answer(25, 6, "Exactly"), new Answer(26, 6, "Yeap!"),
new Answer(27, 7, "yes, I do!"), new Answer(28, 7, "Sure!"), new Answer(29, 7, "Exactly"), new Answer(30, 7, "Yeap!")
}.Where(qa => questions
.Select(q => q.IdQuestion)
.Contains(qa.IdQuestion)
);
}
}


QuestionAnswerRepository. Imitation of getting correct answers of questions from Database:



public class QuestionAnswerRepository : IQuestionAnswerRepository
{
public IEnumerable<QuestionAnswer> GetCorrectAnswers(IEnumerable<Question> questions)
{
return new List<QuestionAnswer>() {
new QuestionAnswer(1, 1),
new QuestionAnswer(2, 2),
new QuestionAnswer(3, 3),
new QuestionAnswer(4, 4),
new QuestionAnswer(5, 1),
new QuestionAnswer(6, 1),
new QuestionAnswer(7, 1),
new QuestionAnswer(8, 1),
new QuestionAnswer(9, 1),
new QuestionAnswer(10, 1)
}
.Where(qa => questions
.Select(q=>q.IdQuestion)
.Contains(qa.IdQuestion)
);
}
}


QuestionRepository:



public class QuestionRepository : IQuestionRepository
{
public IEnumerable<Question> GetQuestions()
{
return new List<Question>() {
new Question(1, "How many are there contintents?"),
new Question(2, "How many are there colours?"),
new Question(3, "What is the tallest tree?"),
new Question(4, "Do you like dolphins?"),
};
}
}


and CountPlayerScoreBySumService:



public class CountPlayerScoreBySumService : ICountPlayerScoreBySum
{
public int CountPlayerScoreBySum(IEnumerable<Answer> playerAnswers,
IEnumerable<QuestionAnswer> correctAnswers)
{
var sum = 0;
foreach (var userAnswer in playerAnswers)
{
var correctAnswer = correctAnswers
.Where(a => a.IdQuestion == userAnswer.IdQuestion)
.FirstOrDefault();

if (correctAnswer != null) {
if (userAnswer.IdAnswer == correctAnswer.IdAnswer)
sum += 1;
}
}

return sum;
}
}


and Factory service:



public class Factory
{
public static T CreateInstance<T>() where T : new()
{
return new T();
}
}


However, my signatures of methods looks like this. Many methods have arguments type of array:



private IEnumerable<Answer> GetPlayerAnswers(IEnumerable<Question> questions, 
IEnumerable<Answer> possibleAnswers)
{
...
}


Is it okay? Is it a code smell to pass collections as arguments of a method? Or my quiz game is not properly designed? If yes, please be very kind, to advice me how design of an application can be improved.



In addition, I've pushed all my code of Quiz game code into GitHub.










share|improve this question











$endgroup$








  • 1




    $begingroup$
    Could you edit your question please and explain what the quiz is about? We need this for context. Otherwise if you're not interested in a general review you should try Software Engineering.
    $endgroup$
    – t3chb0t
    2 hours ago






  • 1




    $begingroup$
    @t3chb0t Thank you for your attention, I've edited my question and explained what the quiz about.
    $endgroup$
    – StepUp
    2 hours ago














2












2








2





$begingroup$


I've seen tutorials of Unit Testing and I've never seen that IEnumerable<T> used as an argument of method. All authors use Repository pattern and Service layers to interact with data, that is, authors of tutorials get data in Service layer by Repository and there is no need to pass collections between the methods of Service layer.



However, I've written a simple quiz game which imitates Repository pattern and when I started writing unit test methods, then I realized that many of my methods has arguments type of IEnumerable<T>.



This is a simple quiz game where user can give simple answers to simple questions . For example, quiz asks question, then program will remember the answer of player and in the end program will calculate the overall score of the player answers. e.g. "How many continents are there on the Earth?", then quiz shows 4 possible answers, and then quiz remembers answers.



The whole code of my quiz game looks like this:



Model classes:



public class Answer
{
public Answer(int idAnswer, int idQuestion, string content)
{
IdAnswer = idAnswer;
IdQuestion = idQuestion;
Content = content;
}

public int IdAnswer { get; }
public string Content { get; }
public int IdQuestion { get; }
}

public class Question
{
public Question(int idQuestion, string content)
{
IdQuestion = idQuestion;
Content = content;
}

public int IdQuestion { get; }
public string Content { get; }
}

public class QuestionAnswer
{
public QuestionAnswer(int idQuestion, int idAnswer)
{
IdQuestion = idQuestion;
IdAnswer = idAnswer;
}
public int IdQuestion { get; set; }
public int IdAnswer { get; set; }
}


Program class:



static void Main(string args)
{
IQuestionRepository questionService = Factory.CreateInstance<QuestionRepository>();
var questions = questionService.GetQuestions();

IAnswerRepository answerService = Factory.CreateInstance<AnswerRepository>();
var possibleAnswers = answerService.GetPossibleAnswers(questions);
var playerAnswers = GetPlayerAnswers(questions, possibleAnswers);
IQuestionAnswerRepository questionAnswerRepository =
Factory.CreateInstance<QuestionAnswerRepository>();
var correctAnswers = questionAnswerRepository.GetCorrectAnswers(questions);

ICountPlayerScoreBySum playerScores =
Factory.CreateInstance<CountPlayerScoreBySumService>();
var playerScore = playerScores.CountPlayerScoreBySum(playerAnswers, correctAnswers);

var winScoreString = ConfigurationManager.AppSettings.Get("WinScore");
int winScore = 0;
int.TryParse(winScoreString, out winScore);

Console.WriteLine( playerScore == winScore ?
$"Wow! You are a winner! Your score is {playerScore}"
: $"Try again! It is just the lesson to win! Your score is {playerScore}");
}


The method GetPlayerAnswers of Program class:



private static IEnumerable<Answer> GetPlayerAnswers(IEnumerable<Question> questions, 
IEnumerable<Answer> possibleAnswers)
{
List<string> allowedAnswers = new List<string>()
{
Constants.Constants.Answers.A,
Constants.Constants.Answers.B,
Constants.Constants.Answers.C,
Constants.Constants.Answers.D,
};

var playerAnswers = new List<Answer>();

foreach (var question in questions)
{
var possibleAnswersViewModel = possibleAnswers
.Where(a => a.IdQuestion == question.IdQuestion)
.OrderBy(a=>a.IdAnswer)
.Select((a, i) => new PlayerAnswerViewModel {
Content = $"{ IntToLetters(i)}. {a.Content}",
IdAnswer = a.IdAnswer,
IdQuestion = a.IdQuestion,
PlayerKey = IntToLetters(i)
});

AskQuestion(question, possibleAnswersViewModel);

while (true)
{
var playerKey = Console.ReadKey().KeyChar.ToString().ToUpper();
Console.WriteLine();
if (!allowedAnswers.Contains(playerKey))
{
AskQuestion(question, possibleAnswersViewModel, true);
}
else
{
var answer = possibleAnswersViewModel
.Where(a => a.PlayerKey == playerKey)
.FirstOrDefault();
if(answer != null)
playerAnswers.Add(new Answer(
answer.IdAnswer,
question.IdQuestion,
playerKey));
break;
}
}
}

return playerAnswers;
}


The methods AskQuestion and IntToLetters of Program class:



private static void AskQuestion(Question question, 
IEnumerable<PlayerAnswerViewModel> possibleAnswers,
bool showPossibleKeys = false)
{
if (showPossibleKeys)
{
Console.WriteLine();
Console.WriteLine("Possible keys are A, B, C or D");
}

Console.WriteLine(question.Content);
possibleAnswers
.ToList()
.ForEach(a => Console.WriteLine(a.Content));
}

public static string IntToLetters(int value)
{
string result = string.Empty;
result = (char)('A' + value % 26) + result;
return result;
}


Repositories:



public interface IAnswerRepository
{
IEnumerable<Answer> GetPossibleAnswers(IEnumerable<Question> questions);
}

interface IQuestionAnswerRepository
{
IEnumerable<QuestionAnswer> GetCorrectAnswers(IEnumerable<Question> questions);
}

interface IQuestionRepository
{
IEnumerable<Question> GetQuestions();
}


And implementation of repositories. AnswerRepository:



class AnswerRepository : IAnswerRepository
{
public IEnumerable<Answer> GetPossibleAnswers(IEnumerable<Question> questions)
{
return new List<Answer>() {
new Answer(11, 3, "Sequoia"), new Answer(12, 3, "Berch"), new Answer(13, 3, "Lindens"), new Answer(14, 3, "Alder"),
new Answer(1, 1, "1"), new Answer(2, 1, "2"), new Answer(3, 1, "5"), new Answer(4, 1, "6"),
new Answer(7, 2, "More than 1"), new Answer(8, 2, "More than 2"), new Answer(9, 2, "More than 5"), new Answer(10, 2, "More than 6"),
new Answer(15, 4, "yes, I do!"), new Answer(16, 4, "Sure!"), new Answer(17, 4, "Exactly"), new Answer(18, 4, "Yeap!"),
new Answer(19, 5, "yes, I do!"), new Answer(20, 5, "Sure!"), new Answer(21, 5, "Exactly"), new Answer(22, 5, "Yeap!"),
new Answer(23, 6, "yes, I do!"), new Answer(24, 6, "Sure!"), new Answer(25, 6, "Exactly"), new Answer(26, 6, "Yeap!"),
new Answer(27, 7, "yes, I do!"), new Answer(28, 7, "Sure!"), new Answer(29, 7, "Exactly"), new Answer(30, 7, "Yeap!")
}.Where(qa => questions
.Select(q => q.IdQuestion)
.Contains(qa.IdQuestion)
);
}
}


QuestionAnswerRepository. Imitation of getting correct answers of questions from Database:



public class QuestionAnswerRepository : IQuestionAnswerRepository
{
public IEnumerable<QuestionAnswer> GetCorrectAnswers(IEnumerable<Question> questions)
{
return new List<QuestionAnswer>() {
new QuestionAnswer(1, 1),
new QuestionAnswer(2, 2),
new QuestionAnswer(3, 3),
new QuestionAnswer(4, 4),
new QuestionAnswer(5, 1),
new QuestionAnswer(6, 1),
new QuestionAnswer(7, 1),
new QuestionAnswer(8, 1),
new QuestionAnswer(9, 1),
new QuestionAnswer(10, 1)
}
.Where(qa => questions
.Select(q=>q.IdQuestion)
.Contains(qa.IdQuestion)
);
}
}


QuestionRepository:



public class QuestionRepository : IQuestionRepository
{
public IEnumerable<Question> GetQuestions()
{
return new List<Question>() {
new Question(1, "How many are there contintents?"),
new Question(2, "How many are there colours?"),
new Question(3, "What is the tallest tree?"),
new Question(4, "Do you like dolphins?"),
};
}
}


and CountPlayerScoreBySumService:



public class CountPlayerScoreBySumService : ICountPlayerScoreBySum
{
public int CountPlayerScoreBySum(IEnumerable<Answer> playerAnswers,
IEnumerable<QuestionAnswer> correctAnswers)
{
var sum = 0;
foreach (var userAnswer in playerAnswers)
{
var correctAnswer = correctAnswers
.Where(a => a.IdQuestion == userAnswer.IdQuestion)
.FirstOrDefault();

if (correctAnswer != null) {
if (userAnswer.IdAnswer == correctAnswer.IdAnswer)
sum += 1;
}
}

return sum;
}
}


and Factory service:



public class Factory
{
public static T CreateInstance<T>() where T : new()
{
return new T();
}
}


However, my signatures of methods looks like this. Many methods have arguments type of array:



private IEnumerable<Answer> GetPlayerAnswers(IEnumerable<Question> questions, 
IEnumerable<Answer> possibleAnswers)
{
...
}


Is it okay? Is it a code smell to pass collections as arguments of a method? Or my quiz game is not properly designed? If yes, please be very kind, to advice me how design of an application can be improved.



In addition, I've pushed all my code of Quiz game code into GitHub.










share|improve this question











$endgroup$




I've seen tutorials of Unit Testing and I've never seen that IEnumerable<T> used as an argument of method. All authors use Repository pattern and Service layers to interact with data, that is, authors of tutorials get data in Service layer by Repository and there is no need to pass collections between the methods of Service layer.



However, I've written a simple quiz game which imitates Repository pattern and when I started writing unit test methods, then I realized that many of my methods has arguments type of IEnumerable<T>.



This is a simple quiz game where user can give simple answers to simple questions . For example, quiz asks question, then program will remember the answer of player and in the end program will calculate the overall score of the player answers. e.g. "How many continents are there on the Earth?", then quiz shows 4 possible answers, and then quiz remembers answers.



The whole code of my quiz game looks like this:



Model classes:



public class Answer
{
public Answer(int idAnswer, int idQuestion, string content)
{
IdAnswer = idAnswer;
IdQuestion = idQuestion;
Content = content;
}

public int IdAnswer { get; }
public string Content { get; }
public int IdQuestion { get; }
}

public class Question
{
public Question(int idQuestion, string content)
{
IdQuestion = idQuestion;
Content = content;
}

public int IdQuestion { get; }
public string Content { get; }
}

public class QuestionAnswer
{
public QuestionAnswer(int idQuestion, int idAnswer)
{
IdQuestion = idQuestion;
IdAnswer = idAnswer;
}
public int IdQuestion { get; set; }
public int IdAnswer { get; set; }
}


Program class:



static void Main(string args)
{
IQuestionRepository questionService = Factory.CreateInstance<QuestionRepository>();
var questions = questionService.GetQuestions();

IAnswerRepository answerService = Factory.CreateInstance<AnswerRepository>();
var possibleAnswers = answerService.GetPossibleAnswers(questions);
var playerAnswers = GetPlayerAnswers(questions, possibleAnswers);
IQuestionAnswerRepository questionAnswerRepository =
Factory.CreateInstance<QuestionAnswerRepository>();
var correctAnswers = questionAnswerRepository.GetCorrectAnswers(questions);

ICountPlayerScoreBySum playerScores =
Factory.CreateInstance<CountPlayerScoreBySumService>();
var playerScore = playerScores.CountPlayerScoreBySum(playerAnswers, correctAnswers);

var winScoreString = ConfigurationManager.AppSettings.Get("WinScore");
int winScore = 0;
int.TryParse(winScoreString, out winScore);

Console.WriteLine( playerScore == winScore ?
$"Wow! You are a winner! Your score is {playerScore}"
: $"Try again! It is just the lesson to win! Your score is {playerScore}");
}


The method GetPlayerAnswers of Program class:



private static IEnumerable<Answer> GetPlayerAnswers(IEnumerable<Question> questions, 
IEnumerable<Answer> possibleAnswers)
{
List<string> allowedAnswers = new List<string>()
{
Constants.Constants.Answers.A,
Constants.Constants.Answers.B,
Constants.Constants.Answers.C,
Constants.Constants.Answers.D,
};

var playerAnswers = new List<Answer>();

foreach (var question in questions)
{
var possibleAnswersViewModel = possibleAnswers
.Where(a => a.IdQuestion == question.IdQuestion)
.OrderBy(a=>a.IdAnswer)
.Select((a, i) => new PlayerAnswerViewModel {
Content = $"{ IntToLetters(i)}. {a.Content}",
IdAnswer = a.IdAnswer,
IdQuestion = a.IdQuestion,
PlayerKey = IntToLetters(i)
});

AskQuestion(question, possibleAnswersViewModel);

while (true)
{
var playerKey = Console.ReadKey().KeyChar.ToString().ToUpper();
Console.WriteLine();
if (!allowedAnswers.Contains(playerKey))
{
AskQuestion(question, possibleAnswersViewModel, true);
}
else
{
var answer = possibleAnswersViewModel
.Where(a => a.PlayerKey == playerKey)
.FirstOrDefault();
if(answer != null)
playerAnswers.Add(new Answer(
answer.IdAnswer,
question.IdQuestion,
playerKey));
break;
}
}
}

return playerAnswers;
}


The methods AskQuestion and IntToLetters of Program class:



private static void AskQuestion(Question question, 
IEnumerable<PlayerAnswerViewModel> possibleAnswers,
bool showPossibleKeys = false)
{
if (showPossibleKeys)
{
Console.WriteLine();
Console.WriteLine("Possible keys are A, B, C or D");
}

Console.WriteLine(question.Content);
possibleAnswers
.ToList()
.ForEach(a => Console.WriteLine(a.Content));
}

public static string IntToLetters(int value)
{
string result = string.Empty;
result = (char)('A' + value % 26) + result;
return result;
}


Repositories:



public interface IAnswerRepository
{
IEnumerable<Answer> GetPossibleAnswers(IEnumerable<Question> questions);
}

interface IQuestionAnswerRepository
{
IEnumerable<QuestionAnswer> GetCorrectAnswers(IEnumerable<Question> questions);
}

interface IQuestionRepository
{
IEnumerable<Question> GetQuestions();
}


And implementation of repositories. AnswerRepository:



class AnswerRepository : IAnswerRepository
{
public IEnumerable<Answer> GetPossibleAnswers(IEnumerable<Question> questions)
{
return new List<Answer>() {
new Answer(11, 3, "Sequoia"), new Answer(12, 3, "Berch"), new Answer(13, 3, "Lindens"), new Answer(14, 3, "Alder"),
new Answer(1, 1, "1"), new Answer(2, 1, "2"), new Answer(3, 1, "5"), new Answer(4, 1, "6"),
new Answer(7, 2, "More than 1"), new Answer(8, 2, "More than 2"), new Answer(9, 2, "More than 5"), new Answer(10, 2, "More than 6"),
new Answer(15, 4, "yes, I do!"), new Answer(16, 4, "Sure!"), new Answer(17, 4, "Exactly"), new Answer(18, 4, "Yeap!"),
new Answer(19, 5, "yes, I do!"), new Answer(20, 5, "Sure!"), new Answer(21, 5, "Exactly"), new Answer(22, 5, "Yeap!"),
new Answer(23, 6, "yes, I do!"), new Answer(24, 6, "Sure!"), new Answer(25, 6, "Exactly"), new Answer(26, 6, "Yeap!"),
new Answer(27, 7, "yes, I do!"), new Answer(28, 7, "Sure!"), new Answer(29, 7, "Exactly"), new Answer(30, 7, "Yeap!")
}.Where(qa => questions
.Select(q => q.IdQuestion)
.Contains(qa.IdQuestion)
);
}
}


QuestionAnswerRepository. Imitation of getting correct answers of questions from Database:



public class QuestionAnswerRepository : IQuestionAnswerRepository
{
public IEnumerable<QuestionAnswer> GetCorrectAnswers(IEnumerable<Question> questions)
{
return new List<QuestionAnswer>() {
new QuestionAnswer(1, 1),
new QuestionAnswer(2, 2),
new QuestionAnswer(3, 3),
new QuestionAnswer(4, 4),
new QuestionAnswer(5, 1),
new QuestionAnswer(6, 1),
new QuestionAnswer(7, 1),
new QuestionAnswer(8, 1),
new QuestionAnswer(9, 1),
new QuestionAnswer(10, 1)
}
.Where(qa => questions
.Select(q=>q.IdQuestion)
.Contains(qa.IdQuestion)
);
}
}


QuestionRepository:



public class QuestionRepository : IQuestionRepository
{
public IEnumerable<Question> GetQuestions()
{
return new List<Question>() {
new Question(1, "How many are there contintents?"),
new Question(2, "How many are there colours?"),
new Question(3, "What is the tallest tree?"),
new Question(4, "Do you like dolphins?"),
};
}
}


and CountPlayerScoreBySumService:



public class CountPlayerScoreBySumService : ICountPlayerScoreBySum
{
public int CountPlayerScoreBySum(IEnumerable<Answer> playerAnswers,
IEnumerable<QuestionAnswer> correctAnswers)
{
var sum = 0;
foreach (var userAnswer in playerAnswers)
{
var correctAnswer = correctAnswers
.Where(a => a.IdQuestion == userAnswer.IdQuestion)
.FirstOrDefault();

if (correctAnswer != null) {
if (userAnswer.IdAnswer == correctAnswer.IdAnswer)
sum += 1;
}
}

return sum;
}
}


and Factory service:



public class Factory
{
public static T CreateInstance<T>() where T : new()
{
return new T();
}
}


However, my signatures of methods looks like this. Many methods have arguments type of array:



private IEnumerable<Answer> GetPlayerAnswers(IEnumerable<Question> questions, 
IEnumerable<Answer> possibleAnswers)
{
...
}


Is it okay? Is it a code smell to pass collections as arguments of a method? Or my quiz game is not properly designed? If yes, please be very kind, to advice me how design of an application can be improved.



In addition, I've pushed all my code of Quiz game code into GitHub.







c# design-patterns collections repository






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago







StepUp

















asked 2 hours ago









StepUpStepUp

261310




261310








  • 1




    $begingroup$
    Could you edit your question please and explain what the quiz is about? We need this for context. Otherwise if you're not interested in a general review you should try Software Engineering.
    $endgroup$
    – t3chb0t
    2 hours ago






  • 1




    $begingroup$
    @t3chb0t Thank you for your attention, I've edited my question and explained what the quiz about.
    $endgroup$
    – StepUp
    2 hours ago














  • 1




    $begingroup$
    Could you edit your question please and explain what the quiz is about? We need this for context. Otherwise if you're not interested in a general review you should try Software Engineering.
    $endgroup$
    – t3chb0t
    2 hours ago






  • 1




    $begingroup$
    @t3chb0t Thank you for your attention, I've edited my question and explained what the quiz about.
    $endgroup$
    – StepUp
    2 hours ago








1




1




$begingroup$
Could you edit your question please and explain what the quiz is about? We need this for context. Otherwise if you're not interested in a general review you should try Software Engineering.
$endgroup$
– t3chb0t
2 hours ago




$begingroup$
Could you edit your question please and explain what the quiz is about? We need this for context. Otherwise if you're not interested in a general review you should try Software Engineering.
$endgroup$
– t3chb0t
2 hours ago




1




1




$begingroup$
@t3chb0t Thank you for your attention, I've edited my question and explained what the quiz about.
$endgroup$
– StepUp
2 hours ago




$begingroup$
@t3chb0t Thank you for your attention, I've edited my question and explained what the quiz about.
$endgroup$
– StepUp
2 hours ago










1 Answer
1






active

oldest

votes


















3












$begingroup$

There is no general rule for using IEnumerable or not but there is one that says that you should use the most abstract representation of something because it gives you the most felxibility.



This means if you are iterating a collection and you do this only once then IEnumerable<T> is perfect because there is virtually nothing more general than this. However, if you plan to use Add or Count or iterate a collection multiple times then something meterialized would be more appropriate like IList<T> or ICollection<T>.




public int CountPlayerScoreBySum(IEnumerable<Answer> playerAnswers, 
IEnumerable<QuestionAnswer> correctAnswers)
{
var sum = 0;
foreach (var userAnswer in playerAnswers)
{
var correctAnswer = correctAnswers
.Where(a => a.IdQuestion == userAnswer.IdQuestion)
.FirstOrDefault();

if (correctAnswer != null) {
if (userAnswer.IdAnswer == correctAnswer.IdAnswer)
sum += 1;
}
}

return sum;
}



Here, e.g. the first argument is ok, it's iterated only once but correctAnswers is used multiple times inside the loop so it probably should be something like IList<T> to make it more predictible and to inform the caller that you are going to use it more then once because it might otherwise execute some lengthly query.



You could also materialize it inside the method but this is not always a good idea and to make such decisions requires to take a look at the big picture and the entire design. Sometimes it's acceptable, another time it might not be the case.



So the bottom line is, don't stupidly use any type because some book says so but rather look carefully which type is the simplest one you can use and gives you the required felxibility at the same time. You have to decide in on case by case basis. You'll mostly end up with IEnumerable<T> anyway but make it a sensible decision and not I've heard that....






share|improve this answer











$endgroup$













  • $begingroup$
    Thanks for so great answer! Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago










  • $begingroup$
    @StepUp your question is only 45min old --- give it some time, I'm sure more answers will appear later ;-)
    $endgroup$
    – t3chb0t
    2 hours ago










  • $begingroup$
    ok. Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");

StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f211982%2fpass-ienumerablet-as-an-argument-of-method-and-repository-pattern%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3












$begingroup$

There is no general rule for using IEnumerable or not but there is one that says that you should use the most abstract representation of something because it gives you the most felxibility.



This means if you are iterating a collection and you do this only once then IEnumerable<T> is perfect because there is virtually nothing more general than this. However, if you plan to use Add or Count or iterate a collection multiple times then something meterialized would be more appropriate like IList<T> or ICollection<T>.




public int CountPlayerScoreBySum(IEnumerable<Answer> playerAnswers, 
IEnumerable<QuestionAnswer> correctAnswers)
{
var sum = 0;
foreach (var userAnswer in playerAnswers)
{
var correctAnswer = correctAnswers
.Where(a => a.IdQuestion == userAnswer.IdQuestion)
.FirstOrDefault();

if (correctAnswer != null) {
if (userAnswer.IdAnswer == correctAnswer.IdAnswer)
sum += 1;
}
}

return sum;
}



Here, e.g. the first argument is ok, it's iterated only once but correctAnswers is used multiple times inside the loop so it probably should be something like IList<T> to make it more predictible and to inform the caller that you are going to use it more then once because it might otherwise execute some lengthly query.



You could also materialize it inside the method but this is not always a good idea and to make such decisions requires to take a look at the big picture and the entire design. Sometimes it's acceptable, another time it might not be the case.



So the bottom line is, don't stupidly use any type because some book says so but rather look carefully which type is the simplest one you can use and gives you the required felxibility at the same time. You have to decide in on case by case basis. You'll mostly end up with IEnumerable<T> anyway but make it a sensible decision and not I've heard that....






share|improve this answer











$endgroup$













  • $begingroup$
    Thanks for so great answer! Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago










  • $begingroup$
    @StepUp your question is only 45min old --- give it some time, I'm sure more answers will appear later ;-)
    $endgroup$
    – t3chb0t
    2 hours ago










  • $begingroup$
    ok. Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago
















3












$begingroup$

There is no general rule for using IEnumerable or not but there is one that says that you should use the most abstract representation of something because it gives you the most felxibility.



This means if you are iterating a collection and you do this only once then IEnumerable<T> is perfect because there is virtually nothing more general than this. However, if you plan to use Add or Count or iterate a collection multiple times then something meterialized would be more appropriate like IList<T> or ICollection<T>.




public int CountPlayerScoreBySum(IEnumerable<Answer> playerAnswers, 
IEnumerable<QuestionAnswer> correctAnswers)
{
var sum = 0;
foreach (var userAnswer in playerAnswers)
{
var correctAnswer = correctAnswers
.Where(a => a.IdQuestion == userAnswer.IdQuestion)
.FirstOrDefault();

if (correctAnswer != null) {
if (userAnswer.IdAnswer == correctAnswer.IdAnswer)
sum += 1;
}
}

return sum;
}



Here, e.g. the first argument is ok, it's iterated only once but correctAnswers is used multiple times inside the loop so it probably should be something like IList<T> to make it more predictible and to inform the caller that you are going to use it more then once because it might otherwise execute some lengthly query.



You could also materialize it inside the method but this is not always a good idea and to make such decisions requires to take a look at the big picture and the entire design. Sometimes it's acceptable, another time it might not be the case.



So the bottom line is, don't stupidly use any type because some book says so but rather look carefully which type is the simplest one you can use and gives you the required felxibility at the same time. You have to decide in on case by case basis. You'll mostly end up with IEnumerable<T> anyway but make it a sensible decision and not I've heard that....






share|improve this answer











$endgroup$













  • $begingroup$
    Thanks for so great answer! Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago










  • $begingroup$
    @StepUp your question is only 45min old --- give it some time, I'm sure more answers will appear later ;-)
    $endgroup$
    – t3chb0t
    2 hours ago










  • $begingroup$
    ok. Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago














3












3








3





$begingroup$

There is no general rule for using IEnumerable or not but there is one that says that you should use the most abstract representation of something because it gives you the most felxibility.



This means if you are iterating a collection and you do this only once then IEnumerable<T> is perfect because there is virtually nothing more general than this. However, if you plan to use Add or Count or iterate a collection multiple times then something meterialized would be more appropriate like IList<T> or ICollection<T>.




public int CountPlayerScoreBySum(IEnumerable<Answer> playerAnswers, 
IEnumerable<QuestionAnswer> correctAnswers)
{
var sum = 0;
foreach (var userAnswer in playerAnswers)
{
var correctAnswer = correctAnswers
.Where(a => a.IdQuestion == userAnswer.IdQuestion)
.FirstOrDefault();

if (correctAnswer != null) {
if (userAnswer.IdAnswer == correctAnswer.IdAnswer)
sum += 1;
}
}

return sum;
}



Here, e.g. the first argument is ok, it's iterated only once but correctAnswers is used multiple times inside the loop so it probably should be something like IList<T> to make it more predictible and to inform the caller that you are going to use it more then once because it might otherwise execute some lengthly query.



You could also materialize it inside the method but this is not always a good idea and to make such decisions requires to take a look at the big picture and the entire design. Sometimes it's acceptable, another time it might not be the case.



So the bottom line is, don't stupidly use any type because some book says so but rather look carefully which type is the simplest one you can use and gives you the required felxibility at the same time. You have to decide in on case by case basis. You'll mostly end up with IEnumerable<T> anyway but make it a sensible decision and not I've heard that....






share|improve this answer











$endgroup$



There is no general rule for using IEnumerable or not but there is one that says that you should use the most abstract representation of something because it gives you the most felxibility.



This means if you are iterating a collection and you do this only once then IEnumerable<T> is perfect because there is virtually nothing more general than this. However, if you plan to use Add or Count or iterate a collection multiple times then something meterialized would be more appropriate like IList<T> or ICollection<T>.




public int CountPlayerScoreBySum(IEnumerable<Answer> playerAnswers, 
IEnumerable<QuestionAnswer> correctAnswers)
{
var sum = 0;
foreach (var userAnswer in playerAnswers)
{
var correctAnswer = correctAnswers
.Where(a => a.IdQuestion == userAnswer.IdQuestion)
.FirstOrDefault();

if (correctAnswer != null) {
if (userAnswer.IdAnswer == correctAnswer.IdAnswer)
sum += 1;
}
}

return sum;
}



Here, e.g. the first argument is ok, it's iterated only once but correctAnswers is used multiple times inside the loop so it probably should be something like IList<T> to make it more predictible and to inform the caller that you are going to use it more then once because it might otherwise execute some lengthly query.



You could also materialize it inside the method but this is not always a good idea and to make such decisions requires to take a look at the big picture and the entire design. Sometimes it's acceptable, another time it might not be the case.



So the bottom line is, don't stupidly use any type because some book says so but rather look carefully which type is the simplest one you can use and gives you the required felxibility at the same time. You have to decide in on case by case basis. You'll mostly end up with IEnumerable<T> anyway but make it a sensible decision and not I've heard that....







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 hours ago

























answered 2 hours ago









t3chb0tt3chb0t

34.2k746116




34.2k746116












  • $begingroup$
    Thanks for so great answer! Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago










  • $begingroup$
    @StepUp your question is only 45min old --- give it some time, I'm sure more answers will appear later ;-)
    $endgroup$
    – t3chb0t
    2 hours ago










  • $begingroup$
    ok. Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago


















  • $begingroup$
    Thanks for so great answer! Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago










  • $begingroup$
    @StepUp your question is only 45min old --- give it some time, I'm sure more answers will appear later ;-)
    $endgroup$
    – t3chb0t
    2 hours ago










  • $begingroup$
    ok. Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
    $endgroup$
    – StepUp
    2 hours ago
















$begingroup$
Thanks for so great answer! Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
$endgroup$
– StepUp
2 hours ago




$begingroup$
Thanks for so great answer! Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
$endgroup$
– StepUp
2 hours ago












$begingroup$
@StepUp your question is only 45min old --- give it some time, I'm sure more answers will appear later ;-)
$endgroup$
– t3chb0t
2 hours ago




$begingroup$
@StepUp your question is only 45min old --- give it some time, I'm sure more answers will appear later ;-)
$endgroup$
– t3chb0t
2 hours ago












$begingroup$
ok. Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
$endgroup$
– StepUp
2 hours ago




$begingroup$
ok. Is it appropriate to ask you here or should I create another question to make a code review of my whole program? Is it possible to get comments of my quiz game?
$endgroup$
– StepUp
2 hours ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Code Review Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f211982%2fpass-ienumerablet-as-an-argument-of-method-and-repository-pattern%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to label and detect the document text images

Vallis Paradisi

Tabula Rosettana