Constant is that which is evident (that is manifest or recorded ) or that has constancy (certainty, perseverance). Something constant is durable, repeated or persistent . For example: "The North American's constant effort led him to a new victory in the tournament" , "My grandfather always tells me that to be successful in business it is essential to be constant and never give up in the face of adversity" , "Students of the Plata is the most consistent Argentine team in recent years .
For mathematics , a constant is a quantity that has a fixed value in a given calculation, process, or equation. This means that the constant is a permanent value that cannot be modified within a certain context. Typically, it is related to a variable (whose values can be modified).
physical constant
A physical constant is the invariable value of a physical quantity over time . An example of this, mentioned very often even in non-scientific fields, is the speed of light in a vacuum (299,792,458 m/s).
When there is, at least in theory , a constant speed, travel times can be estimated. If a car travels at a constant speed of 100 kilometers per hour, it takes four hours to travel a distance of 400 kilometers. Since constant speed does not exist in practice, it is common for this type of estimation to be made with the average speed or average speed.
The concept in programming
In the field of computer programming , a constant is a value that cannot be modified during the execution of a program . It corresponds, therefore, to a fixed length in a reserved area in the computer 's memory.
Its applications, as well as its implementation methods, are diverse; They are generally used to determine values such as minimum and maximum speeds , margins of error, fixed dimensions of elements that must be drawn many times throughout the execution, and numbers of states of the various machines that usually make up a program. This last point is essential, given that the state machine represents a very efficient organization model.
Example of applying a constant
Let's take as an example a very simple application, which presents the user with a form with the fields "name" and "password" to verify the data once entered and which will only be closed once the result is positive. Basically, it can be said that said program will go through the following states from its start to its end:
0: will load the resources necessary for its graphic representation, such as images for the buttons and fonts for the text;
1: will create the form, setting the values of all its components (text entry boxes, labels, buttons, pop-up messages) and display it on the screen;
2: will remain waiting for the user to enter their information and confirm said action;
3: it will proceed to verify the data and will give one of two possible results: "correct", in which case it will be closed; "incorrect", which will result in a state in which it will display a message asking the user to repeat the procedure;
4: while the incorrect data notification is displayed, the program will wait for an action from the user to return to state 1 , probably changing the creation of the form (since it already exists) for a simple cleaning of its input fields.
Although the actual structure of an application is more complex, the example given serves to demonstrate the efficiency and degree of control that the arrangement of states in a machine allows. In the code, which may be different for each programmer, each state is represented by a constant, which is given a name (such as IS_LOAD , IS_WAIT ) and is usually associated with a numerical value.