I need to create some configuration files on a server that will be pulled down by a client application - the remote config file. The client application will also have its own local config file.
In the past I would have just hard coded the logic for reading/writing the config files into the program on both the the client and the server which could create a mismatch if this code is ever updated in the future. Being led in the ways of well-written, easy to maintain code by the esteemed Monks of the Monastery, I am going to write this code as a module that can be installed on both the client and the server. That way, provided both are using the same version of the module, no mismatch will be possible. The first step was to search CPAN for suitable modules.
I didn't expect to find anything that fitted the task perfectly but I did find a few possible candidates of which the top choice would be Config::Simple.
I don't need blocks so want what this module calls a SIMPLIFIED INI-FILE. There are two bits of functionality missing from this module that I need:
- Creating Simplified ini-files
- Fetching the config file from a server
So this gives me three options: (or are there more?)
- Create a module that extends Config::Simple and add the required functionality
- Create a module which makes use of Config::Simple
- Write a module from scratch
In this case I think
3 is most appropriate because
Config::Simple does quite a bit of stuff that I don't want and of the the 3 things I want it to do (read/write/get), I have to write methods for 2 of them.
But this is not a one off situation...how do you decide between extending a class by including that class in @ISA or bringing the class into your class with the use statement and having your module call its methods? Some cases seem clear cut but there is a lot of middle ground where the answer is not clear to me.