Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Construction and configuration

Name: Anonymous 2010-12-28 8:49

I have several classes in my project that rely on configuration files in the same format. All of them are created once only during setup. They are not related, some of them represent simple data structures, others are more complex.
It feels redundant to copy basic file reading/xml parsing across all these classes' constructors, and I want to manage my IO centrally e.g. I don't want client code be able to modify configuration files.
Any cool design patterns that deal with this?

Name: Anonymous 2010-12-28 9:03

Just make a separate class(/classes) that handles IO.
Very simple, very easy.

Name: Anonymous 2010-12-28 9:12

>>2

so I make a class that opens the configuration files, and a structure that contains configuration settings that can be passed to my classes?

Name: Anonymous 2010-12-28 9:59

Perhaps consider a module (or static/singleton class depending on the language) specifically for loading and holding the config info.
It would have a setup/load method that you call on startup that does the parsing and stores the loaded information to be accessed elsewhere.

Name: Anonymous 2010-12-28 10:24

perl 6 and use "grammars"

Name: Anonymous 2010-12-28 12:17

"perl" 6 and "use" "grammars"

Name: Anonymous 2010-12-28 15:24

In Python 2.7, a new means of configuring logging has been introduced, using dictionaries to hold configuration information. This provides a superset of the functionality of the config-file-based approach outlined above, and is the recommended configuration method for new applications and deployments. Because a Python dictionary is used to hold configuration information, and since you can populate that dictionary using different means, you have more options for configuration. For example, you can use a configuration file in JSON format, or, if you have access to YAML processing functionality, a file in YAML format, to populate the configuration dictionary. Or, of course, you can construct the dictionary in Python code, receive it in pickled form over a socket, or use whatever approach makes sense for your application.

Name: Anonymous 2010-12-28 19:18

You're looking for an IoC framework like Spring, or whatever the equivalent is in your chosen language.

Name: Anonymous 2010-12-28 19:28

Consider using the IO monad.

Name: Anonymous 2010-12-28 19:50

Consider using th*** stack overflow

Name: Anonymous 2010-12-28 21:32

design patterns
Now you have two problems.

Name: Anonymous 2010-12-28 23:06

>>11
two problems
Now you have three problems.

Name: Anonymous 2010-12-28 23:50

>>12
three problems
Now you have the perfect number of problems.

Name: Anonymous 2010-12-29 5:43

Is/was Angela Beesley a man?

Name: Anonymous 2010-12-29 15:05

>>14
Sounds like a female name so I guess no?

Name: Anonymous 2013-01-19 23:25

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List