Sunday, April 29, 2012

Back on Track

As I had hoped, my brother-in-law helped set me back on the right track. As I mentioned, he is a skilled developer and really helped me get out of my myopic view that was sending me into a spiral of failure. I think I shall refer to this spiral as Uzumaki (Japanese for spiral, but it sounds cooler). We toyed around with a couple of things and refreshed my memory about how to build a GUI in NetBeans. I've now got a working version of the recipe listing tab where I just need to build the HTML for the recipe output and that tab will be finished.

Moving on, I'm grabbing my notes on the recipe builder page (thank heavens I drew something up a while back) and am building it this morning. I was able to copy the selection triggers and code from the recipe display page to easily create the recipe selection code on the builder page. I've created all the recipe properties and written the code to populate the recipe properties and instructions and ingredient lists whenever a recipe name is selected. I've even finished a button to clear the recipe builder in preparation for storing a new recipe.

Next on the agenda is figuring out how to create JDialogs in NetBeans so I can have popups to add elements to each validated list...

Check that one off the list, too! I am cruising along today, kicking butt and taking names. At this point, it may even be possible to have a working prototype by the end of tomorrow - so I can get to work on the documentation in time for my deadline. This is getting exciting!

I've been putting off writing the full set of logic for deletion requests but to finish the validation editor, think I may need to revisit this. I've got the basics in place for an object to delete its related entry from the database, but now I need to start thinking about foreign key constraints. For example, if a user wants to delete a cooking method, say 'Bake', what will happen to those recipes that already use this method? I think I configured the foreign key constraints to simply set the related values to null (of course, did I configure the object builders to handle nulls?) but am not sure if it will work. The logic I may need to implement is to have the GUI search through the Recipes list for instances of 'Bake' and deny the request to delete it if any are found. That would control the situation without needing to handle the null values, but could get annoying. Then again, unless you recently added one by mistake, why would you delete a method? Especially if you've used it before?

This same set of questions will come up for the other two validations I'm allowing the user to modify as well - ethnicities and food types.

I think this might be a good time to overwrite the equals() methods in my objects. Otherwise, how will I determine if the object chosen for deletion exists in other recipes. If I've coded this program right, the same object should be used in all places, but I have no way of knowing for certain. Should I take the risk?

It is really easy to determine equality for validation package objects because they just have one attribute to compare. So I went ahead and overwrote the equals method on the Ethnicity class and the Method class and was able to successfully set up Add and Delete buttons for them. I still need to do the same for Food Types, but it's late and I need another break. I'll either come back to this tonight or tomorrow morning.

Until next time, be well!

No comments:

Post a Comment