Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Java return intellityping? (http://www.velocityreviews.com/forums/t954112-java-return-intellityping.html)

bob smith 11-01-2012 05:39 PM

Java return intellityping?
 
You know how there are all kinds of typing shortcuts nowadays?

Let's say there's code like this:

m_socket.getOutputStream();

Is there some general way to get your editor (i.e. Eclipse) to create a variable of the correct type and assign it like so:

OutputStream outputStream = m_socket.getOutputStream();

I feel like this could save a lot of work.

Lew 11-01-2012 06:14 PM

Re: Java return intellityping?
 
bob smith wrote:
> You know how there are all kinds of typing shortcuts nowadays?
>
> Let's say there's code like this:
>
> m_socket.getOutputStream();


You should not violate the Java Coding Conventions like this.

> Is there some general way to get your editor (i.e. Eclipse) to create a variable of the correct type and


"General" and "i.e." are not consistent.

It looks like Eclipse Preferences / Java / Editor / Templates is the way to go.
Check your Eclipse documentation.

> assign it like so:
> OutputStream outputStream = m_socket.getOutputStream();
>
> I feel like this could save a lot of work.


http://www.oracle.com/technetwork/ja...nv-138413.html

--
Lew

Andreas Leitgeb 11-01-2012 07:07 PM

Re: Java return intellityping?
 
bob smith <bob@coolfone.comze.com> wrote:
> You know how there are all kinds of typing shortcuts nowadays?
> Let's say there's code like this:
> m_socket.getOutputStream();
> Is there some general way to get your editor (i.e. Eclipse) to create a variable of the correct type and assign it like so:
> OutputStream outputStream = m_socket.getOutputStream();
> I feel like this could save a lot of work.


When I need this, I type some bogus type and the intended varname like this:
Foo outputStream = m_socket.getOutputStream();

Then, eclipse marks it as an error, and among the "Quick-fixes" there's one that
changes my bogus Foo to the actual return-type of the expression.

hth.

Robert Klemme 11-01-2012 10:33 PM

Re: Java return intellityping?
 
On 01.11.2012 18:39, bob smith wrote:
> You know how there are all kinds of typing shortcuts nowadays?
>
> Let's say there's code like this:
>
> m_socket.getOutputStream();
>
> Is there some general way to get your editor (i.e. Eclipse) to create
> a variable of the correct type and assign it like so:


Yes. Mark the code. Then Refactor -> Extract local variable (Alt-Shift-L).

Cheers

robert


--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Jim Janney 11-02-2012 02:49 PM

Re: Java return intellityping?
 
bob smith <bob@coolfone.comze.com> writes:

> You know how there are all kinds of typing shortcuts nowadays?
>
> Let's say there's code like this:
>
> m_socket.getOutputStream();
>
> Is there some general way to get your editor (i.e. Eclipse) to create a variable of the correct type and assign it like so:
>
> OutputStream outputStream = m_socket.getOutputStream();
>
> I feel like this could save a lot of work.


In Eclipse, use Quick Assist - Assign to local variable

Usually bound to Ctrl+2, L

--
Jim Janney

Daniel Pitts 11-02-2012 04:17 PM

Re: Java return intellityping?
 
On 11/1/12 10:39 AM, bob smith wrote:
> You know how there are all kinds of typing shortcuts nowadays?
>
> Let's say there's code like this:
>
> m_socket.getOutputStream();
>
> Is there some general way to get your editor (i.e. Eclipse) to create a variable of the correct type and assign it like so:
>
> OutputStream outputStream = m_socket.getOutputStream();
>
> I feel like this could save a lot of work.
>

In IntelliJ IDEA, you use "introduce variable" (command-ctrl-v), and it
will do exactly that.

I wouldn't be surprised if Eclipse had an equivalent hot-key.

Daniele Futtorovic 11-02-2012 10:00 PM

Re: Java return intellityping?
 
....

You'd think with all that typing time saved, it would translate into
more thinking time.

In my depressing experience, it doesn't. Rather, below a certain
threshold, they appear to be congruent.

_Note_: this is not an argument, it's a </rant>

--
DF.

Lew 11-03-2012 06:58 PM

Re: Java return intellityping?
 
Daniele Futtorovic wrote:
> ...
> You'd think with all that typing time saved, it would translate into
> more thinking time.
>
> In my depressing experience, it doesn't. Rather, below a certain
> threshold, they appear to be congruent.
>
> _Note_: this is not an argument, it's a </rant>


Typing team is not exclusive of thinking time.

--
Lew

Daniele Futtorovic 11-04-2012 04:39 PM

Re: Java return intellityping?
 
On 03/11/2012 19:58, Lew allegedly wrote:
> Daniele Futtorovic wrote:
>> ...
>> You'd think with all that typing time saved, it would translate into
>> more thinking time.
>>
>> In my depressing experience, it doesn't. Rather, below a certain
>> threshold, they appear to be congruent.
>>
>> _Note_: this is not an argument, it's a </rant>

>
> Typing time is not exclusive of thinking time.
>


That's probably the gist of the matter... :)

--
DF.

Daniel Pitts 11-04-2012 05:47 PM

Re: Java return intellityping?
 
On 11/4/12 8:39 AM, Daniele Futtorovic wrote:
> On 03/11/2012 19:58, Lew allegedly wrote:
>> Daniele Futtorovic wrote:
>>> ...
>>> You'd think with all that typing time saved, it would translate into
>>> more thinking time.
>>>
>>> In my depressing experience, it doesn't. Rather, below a certain
>>> threshold, they appear to be congruent.
>>>
>>> _Note_: this is not an argument, it's a </rant>

>>
>> Typing time is not exclusive of thinking time.
>>

>
> That's probably the gist of the matter... :)
>

Often, most of my thinking is done before I start typing, whether it be
to use a shortcut or not. I find that although my available "thinking"
time may not be increased, the time-to-delivery is improved (decreased)
because of shortcuts. I can also use my knowledge that there *are*
short-cuts to allow my to defer thinking and decisions until a later
time. For example, I may be writing a class which might be better as two
classes, but it might not be. I know that I have refactoring tools, so
I'll start with the easiest to implement, and then consider refactoring
when it becomes relevant.


All times are GMT. The time now is 03:13 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57