www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Roles of Variables

reply bearophile <bearophileHUGS lycos.com> writes:
Quoted from the article: "Roles of Variables and Learning to Program" by Jorma
Sajaniemi
http://cs.joensuu.fi/~saja/var_roles/abstracts/didinf05.html

Roles of variables in novice-level procedural programming:
*Fixed value: A variable initialized without any calculation and not changed
thereafter 
*Stepper: A variable stepping through a systematic, predictable succession of
values 
*Follower: A variable that gets its new value always from the old value of some
other variable 
*Most-recent: A variable holding the latest value encountered in going through
a holder succession of values, or simply the latest value obtained as input 
*Most-wanted: A variable holding the best or otherwise most appropriate value
holder encountered so far 
*Gatherer: A variable accumulating the effect of individual values 
*Transformation: A variable that always gets its new value with the same
calculation from values of other variables 
*One-way flag: A two-valued variable that cannot get its initial value once its
value has been changed 
*Temporary: A variable holding some value for a very short time only 
*Organizer: An array used for rearranging its elements

I like that list. Even if it's not complete it covers many important cases.

The "Fixed value" case is so important that in Java the language gives you an
attribute to specify it. So if certain languages have an attribute to specify
the fist case, I ask myself if in a language it can be useful to have
attributes to specify other of those cases. I think not...

Bye,
bearophile
Oct 25 2008
next sibling parent "Denis Koroskin" <2korden gmail.com> writes:
On Sat, 25 Oct 2008 22:02:42 +0400, bearophile <bearophileHUGS lycos.com>  
wrote:

 Quoted from the article: "Roles of Variables and Learning to Program" by  
 Jorma Sajaniemi
 http://cs.joensuu.fi/~saja/var_roles/abstracts/didinf05.html

 Roles of variables in novice-level procedural programming:
 *Fixed value: A variable initialized without any calculation and not  
 changed thereafter
 *Stepper: A variable stepping through a systematic, predictable  
 succession of values
 *Follower: A variable that gets its new value always from the old value  
 of some other variable
 *Most-recent: A variable holding the latest value encountered in going  
 through a holder succession of values, or simply the latest value  
 obtained as input
 *Most-wanted: A variable holding the best or otherwise most appropriate  
 value holder encountered so far
 *Gatherer: A variable accumulating the effect of individual values
 *Transformation: A variable that always gets its new value with the same  
 calculation from values of other variables
 *One-way flag: A two-valued variable that cannot get its initial value  
 once its value has been changed
 *Temporary: A variable holding some value for a very short time only
 *Organizer: An array used for rearranging its elements

 I like that list. Even if it's not complete it covers many important  
 cases.

 The "Fixed value" case is so important that in Java the language gives  
 you an attribute to specify it. So if certain languages have an  
 attribute to specify the fist case, I ask myself if in a language it can  
 be useful to have attributes to specify other of those cases. I think  
 not...

 Bye,
 bearophile
Nice indeed!
Oct 25 2008
prev sibling parent reply Robert Fraser <fraserofthenight gmail.com> writes:
bearophile wrote:
 Quoted from the article: "Roles of Variables and Learning to Program" by Jorma
Sajaniemi
 http://cs.joensuu.fi/~saja/var_roles/abstracts/didinf05.html
 
 Roles of variables in novice-level procedural programming:
 *Fixed value: A variable initialized without any calculation and not changed
thereafter 
 *Stepper: A variable stepping through a systematic, predictable succession of
values 
 *Follower: A variable that gets its new value always from the old value of
some other variable 
 *Most-recent: A variable holding the latest value encountered in going through
a holder succession of values, or simply the latest value obtained as input 
 *Most-wanted: A variable holding the best or otherwise most appropriate value
holder encountered so far 
 *Gatherer: A variable accumulating the effect of individual values 
 *Transformation: A variable that always gets its new value with the same
calculation from values of other variables 
 *One-way flag: A two-valued variable that cannot get its initial value once
its value has been changed 
 *Temporary: A variable holding some value for a very short time only 
 *Organizer: An array used for rearranging its elements
 
 I like that list. Even if it's not complete it covers many important cases.
 
 The "Fixed value" case is so important that in Java the language gives you an
attribute to specify it. So if certain languages have an attribute to specify
the fist case, I ask myself if in a language it can be useful to have
attributes to specify other of those cases. I think not...
 
 Bye,
 bearophile
I'm sure that list is being used in some CS 101 class and the tests all have "label the type of each variable". The day the test is returned there will then be 100 unhappy students arguing that every variable can fall into multiple categories.
Oct 25 2008
parent Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Robert Fraser wrote:
 bearophile wrote:
 Quoted from the article: "Roles of Variables and Learning to Program" 
 by Jorma Sajaniemi
 http://cs.joensuu.fi/~saja/var_roles/abstracts/didinf05.html

 Roles of variables in novice-level procedural programming:
 *Fixed value: A variable initialized without any calculation and not 
 changed thereafter *Stepper: A variable stepping through a systematic, 
 predictable succession of values *Follower: A variable that gets its 
 new value always from the old value of some other variable 
 *Most-recent: A variable holding the latest value encountered in going 
 through a holder succession of values, or simply the latest value 
 obtained as input *Most-wanted: A variable holding the best or 
 otherwise most appropriate value holder encountered so far *Gatherer: 
 A variable accumulating the effect of individual values 
 *Transformation: A variable that always gets its new value with the 
 same calculation from values of other variables *One-way flag: A 
 two-valued variable that cannot get its initial value once its value 
 has been changed *Temporary: A variable holding some value for a very 
 short time only *Organizer: An array used for rearranging its elements

 I like that list. Even if it's not complete it covers many important 
 cases.

 The "Fixed value" case is so important that in Java the language gives 
 you an attribute to specify it. So if certain languages have an 
 attribute to specify the fist case, I ask myself if in a language it 
 can be useful to have attributes to specify other of those cases. I 
 think not...

 Bye,
 bearophile
I'm sure that list is being used in some CS 101 class and the tests all have "label the type of each variable". The day the test is returned there will then be 100 unhappy students arguing that every variable can fall into multiple categories.
Pretty much, yeah, and rightly so. -- Bruno Medeiros - Software Developer, MSc. in CS/E graduate http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Oct 28 2008