CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2009
    Posts
    4

    How design pattern can help if there are too many config items messy around

    Hi all.

    There are one question on design that I want to get some help:

    I just get my hand a project that, the main problem is that there are too many configurable items mess around in certain files.

    I am a PHP programmer so the following will be in PHP, but I think that the principle is the same:

    For example, let say the system has a file called constant.php which, I found that there are more than 400 configurable items inside (all put in a single array). Another file has config items of more than 170.

    My boss and I both think that it is too complicated and it needs to be "implement some architecture", "structured" or "organized" in some way. And this is my job.

    However, I do not have ideas on this. All I think is to imply a singleton pattern to group different kind of config. But I think that there are some more good way to do this and so I would like to ask for some advices from all your experts.

    What would you do if you face such problem? What is the steps that I can perform to analyst this situation?

    Thank you in advance for all your kind help and support.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: How design pattern can help if there are too many config items messy around

    As long as it is an associative array, why exactly is that too complicated? I can understand the number of >400 being somewhat unnerving. But, some large, or even specialized, software packages need that much.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    May 2009
    Posts
    4

    Re: How design pattern can help if there are too many config items messy around

    Thank you for your comment.

    The problem is that, I found it is not "well organized", configs are somewhat "here and there" and the big picture on the whole application become vague when reads these config file.

    My boss asks if we can make it more "better", make it well structured, not so complicated and easily maintainable. And I think that it can be done but how?

    So I need some advices.

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: How design pattern can help if there are too many config items messy around

    Can't you just clean up the configuration options by grouping them?

    What exactly does this software do? What kind of configuration options does it have? Honestly, it sounds almost like a whole rewrite would be easier than to go through all of the code and find 400+ different configuration variables.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    May 2009
    Posts
    4

    Re: How design pattern can help if there are too many config items messy around

    Well that is the tricky part. this is an application which manage a list of contacts. However, there are too many config options which make the whole app clumsy.

    That's why I would like to imply some structure in it, but what should I start first or, what would you do if you were me?

    Thank you again for your comments

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: How design pattern can help if there are too many config items messy around

    Personally, I wouldn't touch it. You're opening yourself up for some really nasty problems when you edit large portions of somebody else's code. You can go through and replace all instances of those defined configuration variables, but if you miss just one, then you can seriously damage functionality.

    If you want to sit back and do a find/replace for 400+ options, then that's up to you and your boss...but it sounds far from worth the time investment. If you didn't create it, cleaning it up is going to take you 10 times longer than the original author.

    Again, it's hard to tell you exactly what to do since we can't really see the exact scenario with all of the includes.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    May 2009
    Posts
    4

    Re: How design pattern can help if there are too many config items messy around

    ok, that's fie, thank you all for your comments.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured