Mark Mintoff My superpower is common sense

11Jul/112

Using Programming for Groceries

This is not something which fits in with the general theme of my blog, but it does involve programming. One of the things which I find irritating, wasteful and unnecessarily time consuming, is grocery shopping. If you want a lean grocery list with little waste, you need to spend time writing a list. If you don't have the time to write a list, you end up impulse buying and then eventually throwing out something when it starts going bad.

I decided that a little bit of programming would resolve this issue. What I resolved to do is type up an XML file with meals and the ingredients required of that meal. For example:

I then used XPath to walk over the XML file, creating a collection of objects. Then X (user-defined) meals are selected at random. The ingredients of each meal are collected together (aggregating the amounts for equivalently named ingredients) and a shopping list is generated. The costs of the ingredients are also aggregated to produce an estimate of the cost of your shopping trip.

My plans for this small application are to also add items which are recurring buys such as coffee, sugar, soap..etc. I am at this stage unsure of how to go about with this. Do I simply tack it onto every shopping list and then check my supplies? I think the best way would be to integrate this with an inventory-style system so that your list would be checked against your stock levels, effectively filtering out the items you already have from your final shopping list. I just wonder on the practicality of keeping an inventory system in a small household.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
22Dec/100

XmlNode Reader

This is a simple little addition I have made to my Helper class today, in order to facilitate reading XMLFiles for settings. It makes use of XPath and is pretty simple: What this does is return a collection of XmlNodes so that you may loop through and get the information necessary. Here is an example of a Configuration-Style XML File: Now what I need to do is get the path attribute for files of type js for the page with the name Default. All I will need to do is: or even Like I said; pretty simple. Basic even. But it saves me a couple of lines of code, so I'm happy about it.
VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)