+ 1

What is hard code?

i sometimes hear about hard coding but i have no clue what it actually is could someone explain thanks.

16th May 2018, 2:44 PM
frank
frank - avatar
3 Réponses
+ 7
This link would make it clear, hopefully. https://en.m.wikipedia.org/wiki/Hard_coding
16th May 2018, 2:51 PM
Dev
Dev - avatar
+ 2
Consider this Eg : int a = 5; int b = 6; int c = a + b ; print(c) In the above code you are assign values in the code itself. This is called hard coding. How many time s you run this code it gives one answer only i.e., 11. Hence hard coding is not a good practice , since input values are decided as per the wish of end user. You should code in such a way that end user can give any input , but at the end your code should give the desired output. I hope you understood. Im not good at english.
16th May 2018, 3:01 PM
Bharath_Teki 🇮🇳
Bharath_Teki 🇮🇳 - avatar
0
For example if you print quoted strings of characters, or do calculations directly using numbers, rather than using variables and constants defined only once in the code, those values are "hard coded". It often makes the software more difficult to maintain, especially if the hard coded values are used (duplicated) in different places, because when you need to change them it is harder to find them all, or remember what the value mean.
16th May 2018, 2:57 PM
ifl
ifl - avatar