Happy New Year everyone! It’s hard to imagine that the 2nd week of the year is just about through… With that being said, this year I’m going to be trying to make it a priority to work on this site much more, and what better way to do it than starting with my first blog post? The following is my two cents on why you should try and make your code dynamic as much as possible.
Over the past several years there have been lots of problems I’ve experienced with code that both myself and teammates have worked where values are hard-coded in. Some of it was out of necessity, some out of pure laziness, and some just from not enough experience.
Think to yourself for a minute… Have you ever experienced source code or scripts that require opening the file and changing it almost every time you need to run it? How much easier would life be if you had taken the time to parameterize the code so this wouldn’t happen? Things would be better, right?
Below is a list of things that would be best to parameterize:
- Sizes of arrays/vectors, especially if it is for system data
- Array/vector locations where data is located
- This one *could be* depending on how quick things need to be and if you know there’s no reason for things to change.
- Network locations
- Passwords
- Security Tokens
- Settings you change while in the program (terminal parameters!)
- Map layouts for games
As you can see, the list appears to be unending. The only drawback would be the time it takes to implement such changes, but even then the time savings could be worth it. The final conclusion that I’ve come to however is:
If you can make it dynamic, do it!