Monday, April 2, 2012

Back in Business

Having finally (FINALLY!) figured out how to get my JDBC driver to load, I've moved on to the next step.  I'm still not feeling the urge to try to figure out the GUI (there's just an overwhelming amount I need to know) and am instead focusing on loading the data from the database and storing it somewhere accessible in the program.

I spent a couple more hours today writing up a validations class which I used to query the database for 8 different validations lists.  These include the list of food types, food stuffs, measurements, fractions, ethnicities, cooking methods, time commitments, and meal parts.  Other than the time commitments and meal parts, theses categories should all be extensible.  Furthermore, by grouping them all into a single class, I just have to have my main program load the class and the loader methods and these lists will be available whenever I need the user to pick from them.  This should, in essence, control user input and only allow accepted, sortable values.  If I reference these later, I should be able to avoid any foreign key failures when trying to update database tables.

The next step is a still a bit nebulous for me.  I have a way to query for validations and can probably use a similar method to query for Recipes, Instructions, Ingredients, Notes, Meals, Daily Plans, and Meal Plans.  However, I'm still trying to decide where to store the master collections of these objects.  I figure that to build the recipe trees in the GUI, I'm going to need a way to create objects for all of these entries in the database and then need a way to iterate through them.  So where should I store a master list?

I'm leaning toward creating a static ArrayList in each class with a load method to populate it from the database.  Then to get the list of recipes, for example, it should be a simple matter of Recipe.getRecipes().  I think.  Another approach would be to create a container class that just maintains these master lists.  I will need ways to sort these lists, convert them to hashes, and search through them, so maybe it's a good idea to put all of these things in the same class.  Or I could keep the lists with the classes and create a Converter class to change them as needed for each usage.  Decisions, decisions...

Of course, the hardest part about planning this is that I don't know what kind of memory hit we're talking about.  I mean, my project is to build a functional skeleton of the program and I think these methods will work swimmingly.  But how far can this program grow with this approach? 100 recipes? 1000? How slow will access be to the foodstuffs list once 10,000 foodstuffs have been entered?

For my purposes, I guess it doesn't matter up front.  If I continue to grow this program after graduation, I'll need to refactor to address these issues, should they come up.  But for now it's best to follow the advice I've been receiving since I first learned to program - know and limit your scope.  Right now, my scope is a skeleton,  and I have a very short time frame to complete it in.  So I will just pick a method and go with it and refactor later if necessary.  And I've decided to keep the master lists with each class and have my main program load them up with the program and just reload them as needed.

Chef Helper is really coming along now.  If I've done this right, I should only have a few major milestones to complete.  The first one after storing these values will be to create modification code in my database objects so I can store new and updated values to the base tables.  I've read about a way to turn my query engine into an interactive sort of system but need to explore it further.  It seems like it's a setting on the ResultSet where I can modify it directly and it will automatically pass on the modifications to the database. We'll have to see about that.

After that little piece, I'll need to finish designing the GUI and figure out how to use Listeners to load and update the screens as they're used and needed.  Once that's tied together and everything is integrated, I'll need to to some testing/debugging (I forgot to include that in my schedule) and then start on the documentation.  I don't recall what all will need to be recorded, but I know the end will include artifacts derived from this blog as well as my ERD and a user's guide for Chef Helper.

So back to the programming for me while I still have some time before going back to work tomorrow. I may need more time off...

No comments:

Post a Comment