Getting configuration data in .Net applications

Managing settings in a .Net application may sound like a simple thing but converting the data types and making sure they are the correct type makes it a bit more difficult.  The biggest problem is that you can end up having disconnected code everywhere doing type conversions and then you have to manage the data from the aspect of caching.  To that end, it is a good idea to create a simple class to keep each of the settings already converted to the correct type in a cache.  One thing to consider is that the cached data will need to be globally accessible and thread safe.

I have created some sample code that demonstrates the principal discussed.  My example code is using the ConfigurationManager library, but if you are using json configuration files this can be easily adapted for that.

Click here to get to my sample code.

Click here for my Gist.

Microsoft Loves Developers

Microsoft Loves Developers.  This is a Microsoft marketing slogan that I have seen at conventions including Microsoft Ignite for the past few years, but until recently I didn’t realize how much Microsoft respected their developers.  There is a lot of divide among the developer community with people who love Microsoft and people who do not, and this is a divide I have never quite understood.

A recent project of mine has involved react-native which means I have needed to use a wide variety of tooling including Xcode from Apple.  Being a developer, I think I need to have the latest and greatest all of the time so I upgraded my Xcode just as I would Visual Studio and didn’t think anything of it.  After the upgrade I received a strange error during the build process of my application which indicated missing files in my build.  Since the project I was developing mostly used the command line I didn’t think anything of the error since and assumed that I had done something to my project causing it to stop building.  The specific error I was receiving was input file cannot be found ‘react-native/Libraries/WebSocket/libfishhook.a’, thus causing me to think it was a missing package file. 

 

 

My problem went from a few hours to a day unable to build my application in Xcode, meaning I was building for Android instead.  When I finally sat down to figure out my problem I heard a co-worker mention something that wasn’t related to my problem but it got me thinking maybe it was Xcode that was the problem.  I finally found the problem, it was a build setting in the workspace in Xcode.  Apple had decided that it was a good idea to use their “New Build System” as the default and this broke my project.  There was no warning or any indication that this would have happened and they would change the build process.  The part that I really do not understand is Apple would assume that I want the new build system, and ultimately my fix was changing this setting to the “Legacy Build System.”

New Build System

With all of my years using Visual Studio and Microsoft products, I had been conditioned that if I do an update to my tooling there wouldn’t be any significant consequences.  When I open a project or solution from Visual Studio that is not compatible with the version I am using, Visual Studio gives me a warning that the solution or project will be upgraded.  It will warn me that it is not reversible and it will prompt me to continue.  Microsoft may encourage you to use their new build options or tooling but they make sure the old one still works for some time after it is deprecated.

Microsoft truly Loves Developers and there is a reason that all Developers should Love Microsoft. 

Promised Acronym

So I have one final thing to say to this whole thing.  Have fun.  Whatever that means for you, for me it is hiding silly easter eggs in apps and making crazy subtle Office references.  If you aren't enjoying doing your work what is the point? 

One last thing… I promised an acronym:

          Be Creative
       Be Open
          Be Humble
  Do unto Others
          Do not be afraid
          Dream
  Deliver Your best

https://www.youtube.com/watch?v=kNdgPeEeJxw

Do not be afraid

What is the worst that can happen?  We have all walked out on that ledge and cowered but sometimes it is the time to jump (metaphorically speaking J).  I have jumped a few times in life and every time I have moved beyond anything I could have imagined. 

Not being afraid does not mean you will not be nervous or anxious about a decision.  When I have gone to a new job I have been anxious and nervous but afraid isn’t a word I would use to describe me. 

Living in a world where I am afraid all of the time would mean that I am not fulfilling my best life and what would be the point.  Being afraid means that I am not trusting in myself and Jesus Christ. 

Cast your cares upon the Lord… He will never let the righteous be shaken - Psalm 55:22.