Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Smart variable declaration
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

znakeeye
Tomato Guru

379 Posts

Posted - Jan 07 2008 :  04:14:23 AM  Show Profile  Reply with Quote
I don't know how many times I write this a day:
CSomeClass someClass;


Wouldn't it be great if there was some fast "Declare a variable of this type, with a decent name"-function? I think there should be something like Ctrl+Enter that does things like this (I'm using acronyms here):
Cmycs Ctrl+Enter yields: CMyClass myClass;\\n
usig Ctrl+Enter yields: unsigned int i;\\n

The variable name should then be selected to let the user decide whether it should be changed or not.

Regarding class instances, I believe the best solution is to remove any leading 'C' and then make the first character lower case. For basic types I guess this is a good trade-off:
char => c
long/int => i
other => var

An extension would be to allow Ctrl+Enter after an asterisk, and insert the following:
CMyClass* Ctrl+Enter yields: CMyClass *pMyClass = new CMyClass(|);
int* Ctrl+Enter yields: int *pVar = new int[|];

Feline, what you say? High five?

feline
Whole Tomato Software

United Kingdom
19024 Posts

Posted - Jan 07 2008 :  2:13:24 PM  Show Profile  Reply with Quote
I do see the appeal, but I can also feel an "enthusiastic discussion" (someone will want me lynched if we do that ) coming on from people who want different naming conventions.

A couple of obvious edge cases:
* class member variables. often these start with "m_" or "_"
* 6 variables in a row of the same type

While testing things I often end up with similar names, but for real world code at least half my variables have "better" names that are more descriptive.

A lot of people hate the idea of using the type as part of the variable name. Personally I find this helpful, especially when working in a scripting language, but again it is down to personal preference.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000