0
How to avoid hard coding a particular value?
I have written a function as follows isNameTrue= funcIF::getinstance.CheckName("abgh6578") how can I avoid hardcoding the above mentioned "abgh6578"? Can I set it as a constant using #define?
1 Antwort
0
Hard coding means writing a program which is not flexible. I.e. there's no way to change the behavior apart from changing the source code. It is highly undesirable because, most of the times it's user who alters the behavior and it could be very unique depending on the situation. There are many ways to overcome this.
• Get the value from the user.
• Get them from stored files (like settings files).
• Get the values from database.
• make use of XML/JSON to get the required settings.
• you can make use of IsolatedStorage or WindowsSettings if you're working on C#.
😀