Java Virtal Machine.net

[ News ] rss

March 18, 2010

Using Spring Security to enforce authentication and authorization on Spring Remoting Services Invoked from a Java SE client.... Spring framework is one of the biggest and the most comprehensive frameworks Java Community can utilize to cover most of the  end to end requirement of a software system when it come to implementation. Spring Security and Spring Remoting are ...

More »

March 18, 2010

TDD/BDD/ATDD Workshop in Melbourne in April. The Testing and TDD for Java Developers workshop is coming to Melbourne again on April 15-16. In my experience (and that of many others), when done well, agile developer testing practices can have a huge and lasting impact on higher code quality, bet...

More »

March/2010
SunMonTueWedThuFriSat
 1 2 3 456
789 1011 12 13
14 15 16 171819 20
21222324252627
28293031   

[ Archives News
for 'Developers' ]

home > news > developers > ruby screenshot of the week #23: extract method and more refactorings!

Ruby Screenshot of the Week #23: Extract Method and More Refactorings!

Last week I promised to catch up on my e-mail, but I had been missing feature work too much during the bug phase so I put it off for a week... to implement some more quickfix refactorings: Extract Method Introduce Variable Introduce Constant Here's how it works. Let's start with "Extract Method". You're looking at some code like this: You decide there's too much going on in this method, and you want to pull the middle section into its own method. Select it, and notice the lightbulb which shows up on the left: Press Alt-Enter to show the quick fix alternatives: Select Extract Method, and the IDE will pop up a dialog asking you for the name of the new method you want to extract from the selected code fragment: Press OK (or just hit Enter), and the code will mutate into the following: There's a lot to notice here. First, there's a new method, and the active selection and caret is on a comment for that method (so you can just type to replace it). The new method is added below the one you extracted code from. And the most important part about this refactoring is that the IDE figures out which variables to pass in to the method, and which variables to pass back out: a, b and d are accessed from within the fragment, so they are passed in. c is reassigned in the fragment without reading the previous value, so doesn't need to be passed in. f and h are assigned locally inside the extracted fragment, but...


Date: November, 12 2007
Url: http://blogs.sun.com/tor/entry/extract_method_introduce_variable_introduce


Others News

Leave a Reply

Name (required)
Mail (will not be published) (required)
Website
You don't see letters?

Enter the code shown above (required)


Related

©2002-2008Java-Virtual-Machine.net