From: Graham Nicholls <"graham_please, no_spam"@...> Date: 2005-07-06T01:40:46+09:00 Subject: Re: A matter of style. Robert Klemme wrote: > Graham Nicholls wrote: >> I'm writing an application to extract data from a dataease database. >> >> It will have 2 main objects ; an input file and a schema. How would >> you organise the code? Would you have a class for each of these >> objects, and a function called, say "extract" which would be passed >> the objects, or would you have a class called extract which owned the >> objects "file" & "schema", and had the method called "extract". Am I >> barking up the wrong tree? (Or simply barking?) I hate writing >> inelegant code - my thinking being that if I get the top level >> structure right, the rest is easy. So, any comments, please. > > Upfront I'd go with the second alternative (3 classes). That way your > file and schema classes are free to be reused in other contexts and > concerns are nicely separated. Also, extraction seems to be quite a > complex operation that needs some state of its own. Think of the > extractor as an implementaion of the command object pattern. > > If any of the three classes is simple (as simple as a file name for > example) then you'd probably want to merge it into the extractor. But > that depends on the complexity and chances for reuse. > > Kind regards > > robert Thanks, both of you. I was beginning to think, yes a third class would be best, then I decided that really "file" owns a "schema". Then perhaps, "extract" owns both a file, which as suggested is pretty simple, really, and a more complex schema. I guess I'll start one way,and simply recode if it all looks wrong! Thanks again. GN -- The answer's always "Yes". Now, what was the question? ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =---