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
 Technical Support
 Name suggestion when declaring a variable
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

BruteForce
Senior Member

Greece
32 Posts

Posted - Sep 21 2008 :  05:50:51 AM  Show Profile  Reply with Quote
A minor improvement would be the following:
When I start to type in a variable declaration then VA should not attempt to suggest me any names.

When I type "ULONG xxx..." VA tries to match my first characters in the identifier with existing variable names in scope and propose one of those names to me, a name that has ALREADY been declared and is thus totally useless for me to use, unless I am in the bad habit of declaring variables with similar names (MyVar1, MyVar2, etc).
So I get an extra annoyance while I am typing, which goes away as soon as the name that I type becomes unique, but still it is an annoyance since I get some more totally unnecessary flashes on my screen.

Warm regards and keep up the great job,
Dimitris Staikos

When all else fails try common sense.

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Sep 23 2008 :  09:45:12 AM  Show Profile  Reply with Quote
VA does not know that you are declaring a variable. You might be writing a function implementation by hand, in which case you are likely to want suggestions.

Also there are times when you have variables and function with similar names, at least this happens in my code, and other code I am familiar with. So it can be useful to accept the suggestion and edit it afterwards.

zen is the art of being at one with the two'ness
Go to Top of Page

BruteForce
Senior Member

Greece
32 Posts

Posted - Sep 23 2008 :  11:37:24 AM  Show Profile  Reply with Quote
quote:
Originally posted by feline

VA does not know that you are declaring a variable. You might be writing a function implementation by hand, in which case you are likely to want suggestions.


You mean VA does not know if the cursor is at file scope or at function scope? As far as I know, in C/C++ you can't start a function body within a function body :-P
Of course you can write a function prototype because you are bored to put it at the top of your source file or in a header but this is rare and a bad habit too.

Most of the time when I type a TYPENAME and then start to type an identifier I want to declare a variable and I am sure VA knows that ;-)

quote:
Also there are times when you have variables and function with similar names, at least this happens in my code, and other code I am familiar with. So it can be useful to accept the suggestion and edit it afterwards.



As I originally said, for a number of reasons variables with similar names in the same scope is a MAJOR bad habit (void *p1, *p2, *p3; int Index1, Index2;), so I think VA should not encourage it.
Anyway, VA saves us all the typing in the world when we USE variables, it could spare us some flashes at the variable declarations :-)

The least VA should do is the following:
If I am typing an identifier and it proposes some names AND I press ESC, then it should shut up until I am DONE with the identifier (the cursor leaves the current identifier).
I pressed ESC and this means "Thanks VA, I don't want any suggestions" so why do the suggestions reappear when I type the next character?

Anyway it is a minor issue, do as you feel about it. In the meanwhile I will try to declare less variables :-P

Warm Regards
Dimitris Staikos

When all else fails try common sense.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Sep 23 2008 :  3:27:43 PM  Show Profile  Reply with Quote
So you never add variables to your classes?

Having Escape turn off suggestions for the duration of the current symbol is an interesting idea, and I have put in a feature request to see what our developers make of this:

case=19918

zen is the art of being at one with the two'ness
Go to Top of Page

BruteForce
Senior Member

Greece
32 Posts

Posted - Sep 24 2008 :  01:58:19 AM  Show Profile  Reply with Quote
Haha, that's a good point! However, most of the time I write device driver code in C so I only use structs ;-) But even there, personally I wouldn't like name suggestions for new members :-D
It's just me I guess :-P

Thanks for submitting 19918! Keep up the great job!

When all else fails try common sense.
Go to Top of Page

BruteForce
Senior Member

Greece
32 Posts

Posted - Sep 24 2008 :  04:17:22 AM  Show Profile  Reply with Quote
Hmmm and while we are at it, here is another idea which I think is interesting.

For example when I am writing MY code I have numerous functions that deal with a SOMETYPE* variable, exactly ONE variable in each function.
In ALL my functions I use exactly the same name for the variable, e.g
SOMETYPE *pSomeType;

The reason I do this is threefold:
(1) If I do a FindInFiles from Visual Studio with "pSomeType" I can quickly see all the places in the code that touch a SOMETYPE* structure. THIS IS A HUGE TIME SAVER.
(2) If I move or copy/paste code from one function to another, the moved/pasted code is immediately valid; I don't have to scan it and rename the variables to whatever local name I happened to use.
(3) I don't have to think every time how to call the variable.

I don't know what others might think about this habit, I think it's good and it has caused me no problems so far.

So the feature I propose is this:
When I am in a function and I start to declare a SOMETYPE* then VA could simply propose the name it has seen me use again and again across all the code in functions that have only ONE variable of this type declared.

That WOULD be NEAT :-)

Warm Regards,
Dimitris Staikos

When all else fails try common sense.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Sep 26 2008 :  10:38:37 AM  Show Profile  Reply with Quote
Try turning on:

VA Options -> Advanced -> Suggestions -> Include bits of code from surrounding lines

VA can get quite good at suggesting things, especially when this is turned on.

Naming conventions vary so widely that making this an actual feature in VA is probably not going to help all that much. However you may find that VA snippets will help. If you create a snippet with a shortcut that uses SOMETYPE as the shortcut, or even just part of this, then you can have it insert the type and matching variable name.

Select a line, Shift + Right click and select "Create VA Snippet from selection..." should help you generate these snippets.

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