Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java return intellityping?

Reply
Thread Tools

Java return intellityping?

 
 
bob smith
Guest
Posts: n/a
 
      11-01-2012
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.
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      11-01-2012
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
 
Reply With Quote
 
 
 
 
Andreas Leitgeb
Guest
Posts: n/a
 
      11-01-2012
bob smith <(E-Mail Removed)> 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.
 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      11-01-2012
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/
 
Reply With Quote
 
Jim Janney
Guest
Posts: n/a
 
      11-02-2012
bob smith <(E-Mail Removed)> 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
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      11-02-2012
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.
 
Reply With Quote
 
Daniele Futtorovic
Guest
Posts: n/a
 
      11-02-2012
....

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.
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      11-03-2012
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
 
Reply With Quote
 
Daniele Futtorovic
Guest
Posts: n/a
 
      11-04-2012
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.
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      11-04-2012
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
difference between return &*i and return i; Ganesh Gella C++ 4 11-12-2004 04:28 PM
getting return value from function without return statement. Seong-Kook Shin C Programming 1 06-18-2004 08:19 AM
How do I return a return-code from main? wl Java 2 03-05-2004 05:15 PM
Return a return value from Perl to Javascript PvdK Perl 0 07-24-2003 09:20 AM



Advertisments