• (nodebb)

    Sometimes the cure is worse than the frist disease.

  • (nodebb)

    It's not unusual to store format templates in your application configuration files. I'd argue it's probably a good and wise thing to do

    Wait! Isn't this the same site that has roundly condemned "Soft Coding" in the past? ( e.g. https://thedailywtf.com/articles/soft_coding )

  • (nodebb)
    tempalte = "th{1}d";
    format(template, "ri");
    

    With XML I find CDATA is your friend. e.g.

    <add key="xxxukl"><![CDATA[anything you like except]]></add>
    

    Addendum 2025-07-02 07:51: Ah, an off by two error

  • (author) in reply to Steve_The_Cynic

    At the same time, destination URLs, for example (or file paths) are frequently things that do have a template structure to them. Left to my own devices, I'd likely not use a format string, admittedly (because yeah, you're right, the order of the elements is well known, just have "domain", "root", and then the API end point is well known). So I shouldn't have called it wise, but it's certainly inoffensive.

  • (nodebb)

    It's not unusual to store format templates in your application configuration files. I'd argue it's probably a good and wise thing to do

    It depends. If team X maintains a software package and team Y installs it, perhaps in several places, then this configuration gives them some flexibility to handle things without passing them off to team X. However, if team X owns the software top to bottom, then it's almost certainly stupid. Why bother assigning a dev the job of changing a config when you can assign the same dev the job of changing the UI? If your answer is "it saves us a deployment", then you are bad at CI/CD, and that's where you should concentrate your effort, not on working around your weaknesses.

  • (nodebb)

    There's an awful lot of "xxx" in that template. Maybe the developer is injecting a popup to his OF into the sales app?

    Using this template to avoid writing "&" is, indeed, stupid. If that were coded into the template rather than be a parameter to string.Format it would have to be considered "sane". This code is a frist for me -- I've never seen anything like it and hope I never do!

  • (nodebb)

    It's not completely unreadable. The word 'pristjek' is Scandinavian and means 'price check'

  • Loren Pechtel (unregistered)
    Comment held for moderation.
  • (nodebb)

    Am I the only one who takes offence at the use of <add key.../>?

    This implies that this XML data structure really acts as a sequence of commands for populating a dictionary. Which raises the question: WHY? Why treat an XML file like a micro language for populating a dictionary instead of just mapping the dictionary to an XML structure?

    Note that the difference would merely be to switch "add" for "entry" or similar. But the implications of the tag "add" on how the programmer was thinking about the problem frighten me.

  • (nodebb) in reply to R3D3

    But the implications of the tag "add" on how the programmer was thinking about the problem frighten me.

    The fact that you believe the programmer was thinking is what frightens me.

  • (nodebb)

    @R3D3: The standard .Net XML configuration system has add semantics. Because it also has remove semantics. There are times and places where that makes sense.

    https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/appsettings/

  • (nodebb) in reply to R3D3

    Why treat an XML file like a micro language

    Same reason some people treat Perl as an operating system...?

Leave a comment on “And Config”

Log In or post as a guest

Replying to comment #681954:

« Return to Article