C#: Changing ‘Magic Number’ Variable to a Config Setting
1 min readJun 24, 2018
The Challenge: A client has requested to extend its 15-day grace period for dues payments to 30 days.
The Solution:
- Find the code setting the grace period. Navigate to VSTS repo and search for “15”, leading to the line(s) of code controlling the grace period variable.
- Load the solution locally through TFS. Open VS17 > Team Explorer > Manage Connections > Connect to client folder and load appropriate solution file. Ensure root path is C:\Code (Source Control Explorer).
- Flip to Solution Explorer and locate the file containing the line of code identified from Step 1.
- Unload the parent directory. Check References to make sure each dependency is properly called. (Look up Properties, F4, for any that are unresolved and relay to correct paths.)
- Refactor the “magic number” variable into an app setting and Build. (Switched Debug to Release.)
- Reload the parent directory and commit change to TFS.
- Connect to remote server following internal documentation.
- Add this new app setting to web config file on iMIS server. Now the “magic number” is a configurable variable that can be easily changed.