From: Travis D Warlick Jr Date: 2007-07-23T10:06:45+09:00 Subject: Re: Class Overkill? What's practical? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Todd Burch wrote: > I'm fretting over how many classes I actually need. Here are the > classes I'm thinking I should have: > > 1) a class to represent the 3D file and methods for reading & validating > it Very good. > 2) a class to represent the resultant bill of material spreadsheets (in > Excel terms a "WorkBook") that will have multiple sheets, with methods > for colorizing, setting cell attributes, etc. Very good. > 3) a class to represent the Excel file that is the lookup table, or > catalog, of all items that could possibly make up a bill of materials, > with methods for opening, closing, reading the headings, and item names, > etc. Very good. > 4) a class to represent the connection from Ruby to Excel that contains > the methods for calling Excel, establishing the connection to Excel, > quitting excel, etc. Very good. > 5) I could have a class for all the headings in the catalog file that > keep track of the column number > > 6) I could have a class for all the item names in the catalog file, and > keep the row number 5 and 6 should be apart of a "Catalog" class, if I understand your design correctly. > But, then I have sections of code that "cut" data from the catalog sheet > and "paste" it into the bill of materials sheet, and which class do I > put that method in? I would probably put it into the "Bill Of Materials" class so that it can "get from Catalog". Make your objects *do* things rather than have things done to them. Hope that has helped. For future reference, take a look at the Unified Modeling Language. It's a good way to develop OO applications: http://en.wikipedia.org/wiki/Unified_Modeling_Language http://www.uml.org/ And a good book: Ambler, Scott William (2004). The Object Primer: Agile Model Driven Development with UML 2. Cambridge University Press. ISBN 0-521-54018-6. - -- Travis Warlick "Programming in Java is like dealing with your mom -- it's kind, forgiving, and gently chastising. Programming in C++ is like dealing with a disgruntled girlfriend -- it's cold, unforgiving, and doesn't tell you what you've done wrong." -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGo/8dWvapaOIz2YYRAjovAJ4/oljoctC/xWlJKvO+ClAwgbU7nQCgmxrr SZ+A4Veyba7PSK4fVp3PQa0= =XkuJ -----END PGP SIGNATURE-----