This is a semi-related question to question to the following question I just raised:
http://stackoverflow.com/questions/1671259/utility-classes-good-or-bad
After determining that a class is to act as a cache for Url parsing rules stored in an XML file, I have considered that a singleton would solve my problem, but introduce global state (although it is only traveling in one direction XML -> parser), and static dependencies.
The design consideration that led me to consider a singleton was: (note that this is a web application that uses a module to catch and parse ALL requests using the same parser)
- I need to cache the url parsing rules stored in the XML, so the class needs to hang around between requests. I also have a method that parses the Url, given the rules, which determines the routing of the request at the HttpModule level.
Is a singleton valid in this case? How would you solve this?