Refactor SandstormConfig in many classes
Jean Morissette <[email protected]> Thu, 16 Dec 2004 14:56:32 -0500
| Newsgroups | gmane.comp.java.seda.user |
|---|---|
| Message-ID | <[email protected]> |
Actually, SandstormConfig has more than 1000 lines of code. This class has many responsabilities: 1- Read the characters in the .cfg file, ignoring comments '#' and handling <!include> directives, with the help of specific java.io.Reader. 2- Parse the readed characters with the help of a StreamTokenizer. After this step, the configuration will be represented in memory by ConfigSection objects. 3- Associate to each stage its own configuration. I think that we should refactor this class to separate these responsabilities in many classes. So we could create (1) a concrete CfgFileReader that encapsulate the complexity of the first responsability and (2) a CfgParser that use the CfgFileReader to create all ConfigSections. Thus, SandstormConfig will use these new classes and only associate to each stage its own configuration. Note that with these changes, ConfigSection should not be an inner class anymore. These changes should help to support new configuration file format like real XML. Indeed, to support a new format, we would just have to create a new Reader and Parser classes; ConfigSection and SandstormConfig would not have to change. What do you think of that? ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/