Thursday, March 09, 2006

Variable Prefixes

When writing Java classes I often label my global variables (fields) with a lower case "f" as prefix. This is just to distinguish from local variables while programming and making. Navigating through my preferences dialog the other day I found a nice option that supports this behavior.

Under Java > Code Style you will find a small table to edit prefix and suffix lists for different variable types.


Now when you create a new field and use code completion (ctrl+space) the assistant suggest a variable name starting with whatever prefix you have specified before.


Very nice feature. It would be even more usefull if it let me type a variable name and then suggest adding a prefix when I press ctrl+space.

3 Comments:

Blogger Nuno Sousa said...

Well, someone is way ahead of your. The latest development millestone from eclipse already suggests suffixes based on the class of the field.

Have a look at the New & Noteworthy page for Eclipse 3.2M5, under JDT Core, Code assist improvement.

2:23 PM

 
Blogger Philipp said...

Not really. I know that feature in Eclipse 3.2 M5. Yes I can type an "f" and let the assistant complete it to "fHashTable" or whatever type it would be. But what I would like to see is, when I type "myVariable" it suggests me "fMyVariable" (adding the prefix I have defined before).

3:40 PM

 
Blogger hfrmobile said...

Such prefixes look like Hungarian Notation and makes me feeling like in the 80's ;-)

8:50 AM

 

Post a Comment

<< Home