Young developer code

A code sequence I’ve found while analyzing some ASP.NET legacy code.

        var isAlpha = string.Empty;
        try { isAlpha = Convert.ToString(Request.QueryString["isAlpha"]); } catch{}

The normal code sequence should be

        var isAlpha = Request.QueryString["isAlpha"] ?? string.Empty;

Writting settings in json

We’ve used to write our settings in xml files. All good, until you want to store the xml files in resources ( to ensure the final user does not mess with the settings, for example).
One of my coworkers suggested a few years ago that we use Json files in such situations; we tried this, and we’ve been doing it ever since.
There are many advantages for our development process, but there are two important disadvantages:
– there’s no schema validation
– one cannot insert comments.
These disadvantages are mitigated at this moment by using specific libraries.
There’s one alternative: HJSON (Human Readable JSON).