Jump to content
UBot Underground

best practice - how do you name your variables/lists/tables?


Recommended Posts

hello!

 

want to ask all you expert coders :)

 

what is your naming convention for variables, lists and tables?

 

reason i ask is because i find with my bots, the bigger they get, the more confused i get... trying to remember what variables have been used and what variable is what is taking time away from productive work.

 

this is especially the case when i am done coding a script and moving on to the next script tab - i don't even need any of the previous variables but they are all there

 

(i like to leave my variables/lists/tables as global just in case i need them in other script tabs though, so it's partly my fault)

 

any tips and tricks you can share in this regard? you have standard prefixes? suffixes?

 

 

THANK YOU so much in advance :)

Link to post
Share on other sites

I use to add various prefixes to my variables, to know where they come from or where are they used, initially...

 

#var_WEB_ usually for scraped data

#var_CYC_ for cycling/looping variables

#var_RND_ for random generated data

#var_LST_ for multiple data that can be split into lists

#var_INP_ for variables sent as input into subroutines/functions

#var_OUT_ for the returns results from same subroutines/variables

 

and so forth....

 

I also tend to add suffixes that would make sense only in certain cases though, such as

..... _CRT for the current value of an incrementable variable in a loop, or

.... _MAX for the maximum value the same above variable might take while looping.

 

My approach makes the code a bit 'meatier' but is more easily readable later than if I would use the simple approach of #var1, #var2 etc...

 

As for lists and tables, for the sake of looking neat among the above variable different prefixes, I prefix them too with tbl or lst ... although, due to the different color coding and initial symbol, it is kinda superfluous most times.

  • Like 3
Link to post
Share on other sites

I use to add various prefixes to my variables, to know where they come from or where are they used, initially...

 

#var_WEB_ usually for scraped data

#var_CYC_ for cycling/looping variables

#var_RND_ for random generated data

#var_LST_ for multiple data that can be split into lists

#var_INP_ for variables sent as input into subroutines/functions

#var_OUT_ for the returns results from same subroutines/variables

 

and so forth....

 

I also tend to add suffixes that would make sense only in certain cases though, such as

..... _CRT for the current value of an incrementable variable in a loop, or

.... _MAX for the maximum value the same above variable might take while looping.

 

My approach makes the code a bit 'meatier' but is more easily readable later than if I would use the simple approach of #var1, #var2 etc...

 

As for lists and tables, for the sake of looking neat among the above variable different prefixes, I prefix them too with tbl or lst ... although, due to the different color coding and initial symbol, it is kinda superfluous most times.

 

yes this method is brilliant for keep track of things ( cause we all know it can become a mess of code after a while on big bots) this post should be stickied so that all new users start to follow the flow this way helps to make a standardized code layout

 

great stuff VB

Link to post
Share on other sites

Thanks, mate!

 

I truly hope it will help people write better code, indeed.

 

What I would also like to see though, is a way to have easily reusable pieces of code that are put into DEFINEs, saved in the Private Bot Bank far more easier than it is right now.

 

It may be my fault?.. BUT I couldn't really make the Private Bot Bank work for me.

 

Categories in it, are great... but I see no need to force a website?.. I may have DEFINEs that have NO relation to any website (think math functions and/or string manipulations, etc...)

 

But I could cope with that thinking outside the box and just setting a fake website there for these - I couldn't SAVE the darn things properly in the end, though...

 

Maybe someone else with more experience might jump in and help explaining how to achieve that?..

Thanks!

  • Like 1
Link to post
Share on other sites

Thanks, mate!

 

I truly hope it will help people write better code, indeed.

 

What I would also like to see though, is a way to have easily reusable pieces of code that are put into DEFINEs, saved in the Private Bot Bank far more easier than it is right now.

Thanks!

 

i also suggested that same thing too , in the enhancment section for new additions, where chunks of common code samples that are basically the building blocks for all bots , yes i second that

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...