[Saute-develop] code split [update]
Status: Alpha
Brought to you by:
heiseltc
|
From: Conan H. <hei...@ya...> - 2001-09-13 08:03:32
|
Hey all, After my second hour of drawing visual representations of the current code and possible future code split ideas, a few more things came clear and some became more complicated. The more we can completely separate the modules (i.e. classes) the better. This will make future developments of a non-database version (perhaps XML flatfile) and a web interface so much easier. Instead of having to go through all of the code and making completely separate versions of the whole thing, we can just add a couple modules and have the program use them instead of the database and GTK+ UI modules. What got more complicated is that we need to figure out how to completely separate the GTK+ GUI from the rest of the code. This is going to take making about every type of data structure into an object and putting it in its own module. Here's the objects and related methods I have so far (my sketch pad with colored markers looks a lot nicer, but this will probably do): 1) recipe : hash of all the recipe data (basically what gets built by get_recipe_info but a hash with the names of each field) - new : creates a blank recipe object if called without arguments, or creates a new one with data if with arguments. - edit : modifies the recipe object - get : returns a recipe given its ID - delete : deletes a recipe (this calls the database module) 2) recipeList : array that goes in the CList in the main window. This will contain all, just recipes from a category, or the results of a search. - new : create a new one (the default is all) - update : modifies the list based on criteria passed to it. 3) database : a connection to the database. all interactions with the database will happen through this object and its methods. - new / connect : create a new connection with the database given the info to connect with (database type, database name, username, password) - query : perform a query and return the results in a reference to an array (similar to DBI's fetchrow_array). This will know what tables to query by the object name passed to it allow with the query criteria - add : create a new entry by the same criteria as query - modify : update a table/tables, as determines like above - destroy / disconnect : end the database session 4) ingredientList : a hash of amount, measure, and ingredient name - new - edit - delete ? - get ? 5) GUI : I'm not sure if this will be an object as well or just a module. Does ALL of the GUI display. This will most likely be the most edited file. - new : make and show the main window - destroy : exit - [lots of internal subroutines] 6) [others will include:] ingredients, search, categories, etc. The main program saute.pl will basically just get the configuration information (in the future this will be in a file in the user's home dir) and calls the GUI to start everything. Well, that's the general ideas starting to come together. I'm still a novice at the whole modules and object oriented thing so comments, suggestions, and disagreements, are very welcome. * On a personal note, I hope everyone is the US is OK. I don't remember anyone being from New York or D.C. but all the same...* conan. __________________________________________________ Terrorist Attacks on U.S. - How can you help? Donate cash, emergency relief information http://dailynews.yahoo.com/fc/US/Emergency_Information/ |