Java Virtal Machine.net

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

April/2024
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
2122232425 2627
282930    

[ 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

©2002-2019Java-Virtual-Machine.net de | website designing software | free website generator | icon font | Bootstrap Templates