iLogic Naming Conventions Explained?

iLogic Naming Conventions Explained?

W_Barnett
Enthusiast Enthusiast
486 Views
3 Replies
Message 1 of 4

iLogic Naming Conventions Explained?

W_Barnett
Enthusiast
Enthusiast

I've been putting together a configurator over the last few weeks.  When I started, I looked for a best practices/naming convention guide, but never really saw one.  However, on almost every single post, I see people using similiar naming styles, such as "oDef", "oSketch", "oThis", or "oThat" - how is everyone so consistent with the same naming style when I was unable to find much information about it, and second, what is the purpose of placing the letter "o" in front of every single variable?  I don't believe that it's a common programming practice, except for use in iLogic, right?

0 Likes
Accepted solutions (2)
487 Views
3 Replies
Replies (3)
Message 2 of 4

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

I can not give an overall explanation. This is not an iLogic convention, it's just an often used practice in programming  to add a letter in front of a variable name signaling the variable type. There are of course not enough letters for all types.

some examples:

s - String

i - Integer

d - Dobule

l - Long

c - Char

o - all Objects who are not in another category

This also prevents using reserved words as variable names.

I'm almost a fan of variable names with "speaking" names. I try to avoid variable names like "a", "b", "s" and so on. Since intelliSense and autoCompletion there's no need to save time with ultrashort names.

I like names giving me a hint what type of variable it is and what type of content it holds. So I would never name a variable "dPartDoc" (Double, PartDocument) that holds a DrawingSheet. This is confusing and makes a code really hard to read and understand, also for other.

 

Anyway, it's just a name and you are free to find a scheme fitting best to your needs.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @W_Barnett.  That variable naming style is mostly just a personal preference of some folks.  Usually just picked up from seeing others do the same thing, and sticking with it, because...why not.  I have used the lowercase letter 'o' for years myself, simply to differentiate variable names I have created from other stuff within the code.  Another common practice is to begin a variable's name with a lowercase letter that represents the data Type of the variable ("s" for String, "d" for Double, "i" for Integer, and "o" for Object, and so on).  And some others don't use any leading lowercase letter, and just use random words or abbreviations of words/phrases as their variable names.  The main thing to address with your variable naming convention is to not name your variable exactly the same as the word/term used to declare the variable's Type, and to name the variable in a way that you (and others who will be working with the code) will understand and recognize.  Some prefer to keep their variable names as short as possible to reduce the overall quantity of code and/or typing, while others prefer to use much longer variable names to help uniquely identify multiple similar variables from each other, and help readability when revisited after a long time.  Whatever works for you and your situation best is probably going to be just fine.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

W_Barnett
Enthusiast
Enthusiast

So many people were using the same coding style, I assumed that there was a formalized convention that was being used.

 

Thanks for the heads up!

0 Likes