Learn something new every day
More Info... by email
In object oriented programming, an object can either hide or reveal its attributes, or state, and behaviors, or methods. An object can be labeled with “public” or “private” modifiers to show or hide information, respectively. Both “private” and “public” are variables, but they are different types of variables. The “public” modifier is a dynamic variable, meaning that the execution of information at run-time of a program is fluid.
All object data and object methods are, by default, dynamic in object oriented programming. Every object in a program has its own dynamic variable and its own dynamic method. That is to say, each object’s execution is fluid at run-time and can change upon re-running the program. This runs in contrast to static variables, in that the static variable is allocated to fixed memory over the life of the program. That is to say that once the variable is allocated to memory space, it is not destroyed at the end of a function.
A variable that is dynamic can be used to collect field values to be used later. The program may use a threshold limit value and compare it to a certain field value processed. Different operation sets are performed for field values, depending on if the value is smaller than or greater than its threshold limit value. A dynamic variable is distinguishable from other variables in that its threshold value can change over the lifetime of a program.
Static variables and dynamic variables are differentiated in that variable values are fixed or fluid, respectively. Variables that are static are similar to constants in mathematics, like the unchanging value of π (pi). Dynamic variables, in contrast, do not have a constant value and therefore, can change a threshold value.
Vending machines are examples of machines that run programs with dynamic variables. The product amount in a vending machine is constantly changing as it is dispensed from the machine. This amount is a dynamic variable, and as its value constantly changes, a program keeps track of the value to determine if the machine needs to be refilled.
When programming any variables, including dynamic variables, it is good practice to name the variable based on the method of the object, or what it does in the program. For example, if there is a certain variable that accounts for shoe size, it could be named “shoe_size.” It is also a normal practice to start the dynamic variable with a lowercase letter and to place an underscore between multiple words.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!