Should my “services” program be responsible for its own configuration?

My program consists of several "services" (I'm not talking about SOA , so do not confuse), and each of these "services" uses some configuration (for example, the path to the directory). This configuration should be read from the configuration file, since they tend to change (without changing the program logic, that is).

So my question is, should each "service" get its own configuration when called, or should it be responsible for getting its own configuration?

This question is really very similar to this question, only my more specific one about it:

  • My "services" of the program are not shared and cannot be reused. They already use common tools, and their functionality is to simply connect these tools. This means that their configuration does not immediately become apparent to them, since their goal is very clear and direct.
  • The purpose of these "services", which is clear and direct, sometimes requires more than one action. This means that my “services” are not necessarily responsible for only one action (although you can separate the logic and drugs such as configuration).

Thanks.

+3
source share
2 answers

I would advocate a combination of these approaches until you manage to implement it in an elegant way (I saw this in both elegant and terrible implementations):

  • , ( Perl - , , ). ,

    • Singleton

    • A " "

  • , :

    • " "

    • ,

    • .

  • , , , ( , ).

, , .

+2

, - , (, , ). , , "".

, , , , , db, URL- , .., smtp- .. , .

, , " " , , .

0

All Articles