okay, assume you had a set of functions whose purpose was the following
A) a function that adds a variable to an object and sets it to a value specified ONLY if the variable doesn't already exist.
B) a function that modifies a variable in an object if it already exists, otherwise if it does not already exist, it does nothing.
C) a function that modifies a variable if it already exists, or creates it and sets it to the value specified if it does not already exist.
What I need are the best names for these 3 types of functions. I want names that are short, but really evocative of what they do, as there will be a number of each type of functions to work on different data types and such.
My initial thoughts are
A) AddVar
B) SetVar or ModVar (for modify variable)
C) SOAVar or MOAVar (for "Set or Add var", or "Modifiy or Add var")
I suppose these seems like a stupid question, but I just want the names to be really clear and yet short, as they will be used all over in my behavior system module, and since I'm hoping others will find it useful, I want to make it as clear and as understandable (and easy to read) as possible.
I'm wondering if "SetVar" is a bad choice - would most of you assume that "SetVar" would add the variable specified if it didn't already exist? Imagine the following call
SomeObject.SetVar( "TestVariable", "test value" )
What this really does is set the variable named "TestVariable" to the string "test value" if and only if "TestVariable" already exists in SomeObject. Is this what you would assume, or does it seem like with a name of "SetVar" it should create the variable if it doesn't already exist? That's why I was thinking "ModVar" might be more descriptive, as usually you can only Modify that which already exists.
Ah, the joys of designing code meant to be read by others :P.
A) a function that adds a variable to an object and sets it to a value specified ONLY if the variable doesn't already exist.
B) a function that modifies a variable in an object if it already exists, otherwise if it does not already exist, it does nothing.
C) a function that modifies a variable if it already exists, or creates it and sets it to the value specified if it does not already exist.
What I need are the best names for these 3 types of functions. I want names that are short, but really evocative of what they do, as there will be a number of each type of functions to work on different data types and such.
My initial thoughts are
A) AddVar
B) SetVar or ModVar (for modify variable)
C) SOAVar or MOAVar (for "Set or Add var", or "Modifiy or Add var")
I suppose these seems like a stupid question, but I just want the names to be really clear and yet short, as they will be used all over in my behavior system module, and since I'm hoping others will find it useful, I want to make it as clear and as understandable (and easy to read) as possible.
I'm wondering if "SetVar" is a bad choice - would most of you assume that "SetVar" would add the variable specified if it didn't already exist? Imagine the following call
SomeObject.SetVar( "TestVariable", "test value" )
What this really does is set the variable named "TestVariable" to the string "test value" if and only if "TestVariable" already exists in SomeObject. Is this what you would assume, or does it seem like with a name of "SetVar" it should create the variable if it doesn't already exist? That's why I was thinking "ModVar" might be more descriptive, as usually you can only Modify that which already exists.
Ah, the joys of designing code meant to be read by others :P.