From: Robert Klemme Date: 2005-07-06T00:35:45+09:00 Subject: Re: A matter of style. 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