Tuesday, May 8, 2012

Meal Randomizer

Now that I've laid the groundwork for Chef Helper and a user can view formatted recipes, build recipes using customizable components, and create full meal plans, it's on to the little tidbit of functionality that prompted this venture from the beginning. Of course I'm referring to the meal randomizer. Though I've built menu plans to hold up to 6 recipes, for appetizer, main course, two sides, dessert, and a beverage, the randomizer is going to start by being focused on main dishes. For one thing, I'm not quite sure how to have it pick complimentary foods to put together and for another, who has time to regularly cook a main dish, two sides, an appetizer, a dessert, and a custom beverage? Exactly.

I've been giving a lot of thought to how best to accomplish this. Iterating through recipe lists should be fairly simple and straightforward. If I shoot for a simple randomizer to start (I can always add complex logic later that looks at spreading out costs, ethnicities, primary foods, etc), I should be able to get this part done fairly quickly. I'm thinking I'll have the user create the meal plan framework which will create all the daily plans and meals to work with and then just iterate through these lists, filling in the blanks.

Remember when I said quickly fairly quickly? It should come as no surprise that I was wrong. To start with, some of yesterday's work didn't get saved (or I totally overlooked something) so I spent most of my time this evening tracking down those bugs and using a different algorithm for creating daily plans from the meal planner.

I'm now running into another problem with the randomizer. I've got it set to search through the master recipe list for recipes with a meal part of main dish. I can't get the equivalency to work! No matter how I do the search, I can't seem to figure out how to find these matches. I think part of this might also be related to my Recipe Builder snafu where I can't get meal part, ethnicities, food types, and commitments to update or store correctly.  So I went back to try to locate these failures. Ironically, they seem to be the same type of errors I'm hitting with the randomizer.

I think part of the problem is the difference between what's in the database and what's loaded in the master lists. I update those damned master lists after almost every transaction, but it still seems like I can't get them to match up. I'm wondering if I'm going to have to recode chunks of the writers and loaders to solve this problem. I sure hope not, but this program has reached a level of complexity where I've lost track of what it's doing.

In fact, despite the looming deadline, I'm thinking I will finish tonight's work with some code cleanup and go through each class and add the comments describing each step. Maybe that will help me wrap my mind around how I decided to code each phase. I'll just have to work on the functional coding again tomorrow when I've taken some time to refamiliarize myself with my design. Sometimes it stinks to have a memory as bad as mine!

No comments:

Post a Comment