Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to manage application configuration ?

How to manage application configuration ?

Scheduled Pinned Locked Moved C / C++ / MFC
hardwaredata-structuresjsontutorialquestion
6 Posts 3 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I am asking for suggestions on how to manage multi object application configuration. I have a hardware intensive application where objects contribute to overall application configuration. Some objects require knowledge / access of / to previously configured objects - there is required sequence in building the application configuration. I do have a main/ primary object and sort of tree structure (menu driven) of the rest of them . Where would be the most logical place to build and keep the commonly accessible "configuration object "? Should it be a separate object or part of the "main object" ? Thanks

    Mircea NeacsuM J 2 Replies Last reply
    0
    • L Lost User

      I am asking for suggestions on how to manage multi object application configuration. I have a hardware intensive application where objects contribute to overall application configuration. Some objects require knowledge / access of / to previously configured objects - there is required sequence in building the application configuration. I do have a main/ primary object and sort of tree structure (menu driven) of the rest of them . Where would be the most logical place to build and keep the commonly accessible "configuration object "? Should it be a separate object or part of the "main object" ? Thanks

      Mircea NeacsuM Offline
      Mircea NeacsuM Offline
      Mircea Neacsu
      wrote on last edited by
      #2

      I'd say it doesn't matter. There are pros and cons to each solution. If you make it part of the main object you have fewer global/high-level objects but every time you access the configuration you go through the main object. This means at least more typing. If you make it a separate (global) object, the opposite is true. My own take: some years ago I was going with the config as part of the main object for reasons of "code purity". These days I go with a separate object for pragmatic reasons.

      Mircea

      L 1 Reply Last reply
      0
      • Mircea NeacsuM Mircea Neacsu

        I'd say it doesn't matter. There are pros and cons to each solution. If you make it part of the main object you have fewer global/high-level objects but every time you access the configuration you go through the main object. This means at least more typing. If you make it a separate (global) object, the opposite is true. My own take: some years ago I was going with the config as part of the main object for reasons of "code purity". These days I go with a separate object for pragmatic reasons.

        Mircea

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Thanks for the reply, I am looking into modification of your "separate object" by building static library.

        1 Reply Last reply
        0
        • L Lost User

          I am asking for suggestions on how to manage multi object application configuration. I have a hardware intensive application where objects contribute to overall application configuration. Some objects require knowledge / access of / to previously configured objects - there is required sequence in building the application configuration. I do have a main/ primary object and sort of tree structure (menu driven) of the rest of them . Where would be the most logical place to build and keep the commonly accessible "configuration object "? Should it be a separate object or part of the "main object" ? Thanks

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          Presuming that I understand what you are saying.

          Member 14968771 wrote:

          Some objects require knowledge / access of / to previously configured objects

          That is basically an incorrect way to think of that unless you stated it incorrectly. You have class A1 which can have an instance a1. Now a1 not A1 is the only thing that is 'configured'. Then there is class B1 which has instance b1. And instance b1 needs access to a1. Note that b1 does NOT have access to the configuration for a1. It should not even know that a1 is 'configured'. Conversely if b1 needs access to the same configuration information as a1 then the configuration information should not be limited to a1 but should be generic. As an example if you have UI objects that represent a Box and a Button and both use a 'configured' color X then you would call that X something like 'outline.color.border'. You would not call it 'Box.color.border' Now AFTER you figure out the hierarchy of the configuration data then you figure out the best way to manage it. Generally you would have a parallel set of configuration objects which in some way are related to each other and which expose the loaded configuration data. C#, as one example, has a dynamic class structure which supports creating from configuration files. But the same thing can be achieved (and perhaps is easier to understand) just by have one class with a method that takes a name and returns a value. But regardless the configuration object (or objects) is entirely independent from the classes that use the configuration. As a reminder do not forget about error handling and default values. If the configuration file is not found or a configuration value is missing (because it is misspelled) then what do you want the application (and objects) to do.

          L 1 Reply Last reply
          0
          • J jschell

            Presuming that I understand what you are saying.

            Member 14968771 wrote:

            Some objects require knowledge / access of / to previously configured objects

            That is basically an incorrect way to think of that unless you stated it incorrectly. You have class A1 which can have an instance a1. Now a1 not A1 is the only thing that is 'configured'. Then there is class B1 which has instance b1. And instance b1 needs access to a1. Note that b1 does NOT have access to the configuration for a1. It should not even know that a1 is 'configured'. Conversely if b1 needs access to the same configuration information as a1 then the configuration information should not be limited to a1 but should be generic. As an example if you have UI objects that represent a Box and a Button and both use a 'configured' color X then you would call that X something like 'outline.color.border'. You would not call it 'Box.color.border' Now AFTER you figure out the hierarchy of the configuration data then you figure out the best way to manage it. Generally you would have a parallel set of configuration objects which in some way are related to each other and which expose the loaded configuration data. C#, as one example, has a dynamic class structure which supports creating from configuration files. But the same thing can be achieved (and perhaps is easier to understand) just by have one class with a method that takes a name and returns a value. But regardless the configuration object (or objects) is entirely independent from the classes that use the configuration. As a reminder do not forget about error handling and default values. If the configuration file is not found or a configuration value is missing (because it is misspelled) then what do you want the application (and objects) to do.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Let me try differt way of describing / expressing the problem Object A builds a "CONFIG A" Object B needs access to "CONFIG A" to build "CONFIG B" Object C needs both "CONFIG A" and "CONFIG B" to operate. I am working on building a library , hence common access, where to "store" both "CONFIG A" and "CONFIG B". PS The example may be illogical - only "CONFIG B" shlud be needed by object C....

            J 1 Reply Last reply
            0
            • L Lost User

              Let me try differt way of describing / expressing the problem Object A builds a "CONFIG A" Object B needs access to "CONFIG A" to build "CONFIG B" Object C needs both "CONFIG A" and "CONFIG B" to operate. I am working on building a library , hence common access, where to "store" both "CONFIG A" and "CONFIG B". PS The example may be illogical - only "CONFIG B" shlud be needed by object C....

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              No that doesn't help at all. Making it as simple as I can... There is a set (one or more) objects that use the configuration. There is another set (one or more) objects that manage the configuration (lets say read it from a file.) The two sets must not be the same.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups