delphi - What's the best way to pass configuration to application agnostic modules? -


I am working on an application that includes several modules which in turn will be used in other applications. Each of these modules requires some configuration options, but should not be aware of the options of the other modules, and other modules should not even exist. Settings for module A are required for Wi and J.

Settings either in the registry or one or more. IE files

So far, I have considered the following methods:

  1. is a global unit ("GlobalSheed") which is included in all modules and with global variables I do not like this approach very much because in this case, all applications will require this kind of unit and it is bound to collect a lot of additional code, which has nothing to do with the original purpose. So eventually each app will have its own incompatible global unit.
  2. For each module there are configuration squares, which contain all the settings needed for that module. These modules are passed from some central point in the application which reads and writes them to some permanent forms (such as using JvAppStorage). It requires some synchronization between the modules, because some options are shared between them, so if the option turns into a module, then this change should be reflected in the configuration of any other module (not necessarily actual In time but next time the module is initial).
  3. A normal configuration class has been passed to each module and it includes settings for properties as properties for all modules. Each module only accesses the settings that it knows that here may be the problem, even after the name conflict is possible. Apart from this, I do not have the necessary requirements for those models which do not like the idea of ​​passing those options. In addition, in each application there will be a separate subtag of the module, but with the same options for all possible modules with the same configuration The class will end. (This is not very different from the viewpoint of the above global entity.)
  4. is a general configuration class given to each module, such as above. But instead of properties, they use their settings by module name (in the simplest case it can be a TCustomIniFile) it avoids the settings for all the modules available in all applications, but introduces compatibility issues possible. And then, name conflicts can become an issue (unless each module prefixes its options with its names, but then those options are not shared can do).

I think those people who have written a modular system have faced this issue and found that they were trapped with some later solutions, even if they still like them Are or Not? I have been there too, many times and still looking for a golden bullet.

Maybe someone else has already got the ideal solution?

(In this case, in case Delphi 2007 is already using JCL / JVCL.)

I would probably create a normal configuration class, and each module is dependent on one or several solid configuration sections, which are unity. A module relies on a configuration class instance with important settings for that module, and optionally with one or more other configurations related to more than one module on class instances. Due to the fact that configuration objects are a one-handed module that automatically obtains the same settings as the configuration object.

You will create the configuration class according to the functionality, not the module according to the use. Uses a module, which requires configuration objects.

Each module that is added to an application adds all the required configuration class as dependency, other configurations classes are not added. Singleton Configuration Objects add itself to a list of such objects on the application startup (or the registry if you do). There is no need to know about the information about the application, just loading and saving settings and is sufficient for continuous storage if O.TO.H. , OTOH can use the same structure.

Normally I will apply everything in the case of the interface, and will leave the system firmly outside. In this way you will be free to configure ini files, registry, or even a database (which will give you an easy way to implement the history of the configuration changes) I have found that I do not have much of myself Because I have started programming against the interfaces instead of classes hierarchies.


Comments