<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Xebia Blog &#187; refactoring</title>
	<atom:link href="http://blog.xebia.com/tag/refactoring/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com</link>
	<description>Software development done right!</description>
	<lastBuildDate>Wed, 01 Feb 2012 00:30:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>IntelliJ 8: Introduce Parameter Refactoring</title>
		<link>http://blog.xebia.com/2008/11/06/intellij-8-introduce-parameter-refactoring/</link>
		<comments>http://blog.xebia.com/2008/11/06/intellij-8-introduce-parameter-refactoring/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 21:16:36 +0000</pubDate>
		<dc:creator>Erik Pragt</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[IntelliJ]]></category>
		<category><![CDATA[intellij 8]]></category>
		<category><![CDATA[refactoring]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=788</guid>
		<description><![CDATA[IntelliJ 8 provides 7 new refactorings. One new powerful refactoring is the Introduce Parameter Object. The name speaks for itself: it introduces a parameter object! But what does it really do? The refactoring promotes good encapsulation. It encapsulates fields by introducing a new object for them. For example, you might encounter or write the following [...]]]></description>
			<content:encoded><![CDATA[<p>IntelliJ 8 provides 7 new refactorings. One new powerful refactoring is the Introduce Parameter Object. The name speaks for itself: it introduces a parameter object! But what does it really do? The refactoring promotes good encapsulation. It encapsulates fields by introducing a new object for them. </p>
<p><span id="more-788"></span></p>
<p>For example, you might encounter or write the following piece of code:</p>
<pre lang="java">
public class Parser {
    public void parse(String firstName, String lastName) {
       // firstName and lastName handling here
    }

    public void testParser() {
        new Parser().parse("erik", "pragt");
    }
}
</pre>
<p>The method call consists of two Strings, but a better approach might be to encapsulate those fields into a new class, for example &#8216;Name&#8217;. This refactoring does exactly that. Just select the &#8216;parse&#8217; method, go to <b>Refactor -> Introduce Parameter Object</b>, which will look like:</p>
<p><img src='http://www.javaisp.net/~erikp/IntroduceParameterObject.jpg' alt='' class='alignnone' /></p>
<pre lang="java">
public class Name {
    private final String firstName;
    private final String lastName;

    public Name(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }
}

public class Parser {
    public void parse(Name name) {
      // name handling here
    }

    public void testParser() {
        new Parser().parse(new Name("erik", "pragt"));
    }
}
</pre>
<p>After refactoring, you&#8217;re code will look like this, which is a much better typed version of the previous one!</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2008/11/06/intellij-8-introduce-parameter-refactoring/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2008%2F11%2F06%2Fintellij-8-introduce-parameter-refactoring%2F&amp;title=IntelliJ%208%3A%20Introduce%20Parameter%20Refactoring" id="wpa2a_2"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2008/11/06/intellij-8-introduce-parameter-refactoring/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  blog.xebia.com/tag/refactoring/feed/ ) in 0.47537 seconds, on Feb 9th, 2012 at 4:18 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 9th, 2012 at 5:18 pm UTC -->
