- Home /
Cooking System Help
So i have this cooking system with an array called cookingList that has a size of 3. Depending on what is in the list dictates the result item so for example if the list contains an apple, a carrot, and a cabbage, the result will be a vegetable soup. I would like to know a good system that searching through a list of recipes and how to define that recipe. Right now my method would be to do a series of if statements like if(cookinglist contains x, y, z) { add item c } Though i feel as if this would be quite inefficient and provides a poor workflow
Answer by TreyH · Jul 03, 2018 at 01:08 AM
To answer the question, yes this is a direct application of something called a Graph Database and an exact example is outlined in this article. But, depending on your experience with these sorts of databases, development might be a bit clumsy at first.
With that said, there's a line between healthy inquiry into possibilities and premature optimization that bogs down your development pipeline. You're right that for a "large" number of potential recipes, this might be a bit slow to use a naive lookup with one ingredient at a time. But, you might want to go ahead and implement this naive format wrapped in a manager / "store" class to get started. Something like:
public class RecipeStore
{
// constructor
public Recipe[] GetRecipes(params Ingredient[] ingredients)
{
// Whatever you'd use to get possible dishes
}
}
This way you can get started and see this working, rather than get slowed down by the details of nodes, edges, and queries. Then later (once your performance starts to suffer from the number of recipes to sort through), you can start to implement a more optimized method into your GetRecipes
calls.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How to select certain Elements in a list using LINQ-methods? 3 Answers
Accessing local system ( File Browser ) 2 Answers
How to get a list of particles 1 Answer