8
What the term means Hard Coded?
It is considered a bad programming practice?
How to exemplify a code Hard Coded and its consequences from development to end-user use?
8
What the term means Hard Coded?
It is considered a bad programming practice?
How to exemplify a code Hard Coded and its consequences from development to end-user use?
8
What does the term Hard Coded mean?
It means that information relevant to the functioning of the system has been placed in the code. In general we are talking about data, but in more specific cases it can be a behavior, often using a system of plugins.
Not to be confused with magic numbers.
An example is to put a password in the code, maybe to test if the person typed a valid one, this is a security problem for several reasons, some not so obvious, is bad, is inflexible.
You put the tax rate on something and the government changes that value, the only way to change that is to change the code, recompile and do the deploy again, having to make a change in execution, which in some scenarios is bad.
You put that will create 4 threads and enters an environment that has 2 or 8 processors, and is not as optimized as it could because the number is hard coded executable (because it was in the code).
You have it recorded in C:, but the user made a different installation and he does not have or does not want to use C: to record something, ready, you are in a nozzle pool.
A function works with 10 items on something it receives, but at some point there is a change and comes 12 items that you should evaluate.
You create an object in a fixed form, but in the future there may be other possible objects for that scenario. Of course it depends on the scenario as it is used to consider so.
You establish how is a data format that must come from somewhere, can be a query to the database, if the source changes its structure has to change the application. I’m not making sense if this is good or not, everything has advantages and disadvantages, this is i case that many applications are hard coded and this is good, because it is rare to have advantages or even possible to be truly flexible without having important costs.
There are cases of middle ground, the executable is hard coded, but not in the code. This helps the development and for some cases may be just what you want, not always eliminate from the executable is the goal. In general we use code generators for this, it greatly facilitates maintenance without generating running costs.
You should ask for any service (it may be the operating system or even something external) what to use, or put data in external configuration file or other utility, or in a database, or other way that does not come from the code.
It’s the good old indirect that solves this.
It is considered a bad programming practice?
It depends on the context, in some it is yes, in others it may be the opposite. I have given examples. Why would I ask for an external source how many days of the week are there? Why would I impose an additional cost without a clear gain?
How to exemplify a Hard Coded code and its consequences from development to end-user use?
I’ve answered before?
0
Depends on the context.
In English, in the context of progression, Hardcoded can mean that a certain value is static. When we declare, for example, nome="João Silva"
, we are defining that the variable nome
has the static value "João Silva"
. This variable is therefore "hardcoded". If, on the other hand, we have the same variable defined as follows: nome=primeiroNome + sobrenome
, being name and surname other two variables, the value of nome
is no longer static and varies according to the value of the other two variables.
In particular, I have never heard or read this word, in English texts or videos, with other connotations.
Browser other questions tagged terminology performance
You are not signed in. Login or sign up in order to post.
I edited the answer because it should only have information that answers the question. If you have another question, enough ask another question - but if the question is more about the Portuguese language and less about programming, I suggest you do it here. As to the question itself, yes, it is normal and perfectly acceptable - read Help Center to better understand
– hkotsubo
As for the use of the term "hardcoded", it may even be that the original meaning is what you mentioned, but in programming - at least in Brazil - he ended up gaining other uses and connotations - all of them, incidentally, cited in the other answer, so in my view there is no misunderstanding in it
– hkotsubo
Just to finish, in this case it was not the same person who asked and answered. The one who answered only edited the question, so her name also appears there. But anyway, even if it had been the same person, that would be perfectly normal, as said above
– hkotsubo
Thanks for the guidelines. I asked about the equivalent of the term in the forum indicated.
– tirmey