<?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>EclipseSource Blog &#187; jdt</title>
	<atom:link href="http://eclipsesource.com/blogs/tag/jdt/feed/" rel="self" type="application/rss+xml" />
	<link>http://eclipsesource.com/blogs</link>
	<description>Eclipse Equinox OSGi</description>
	<lastBuildDate>Fri, 18 May 2012 15:00:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Type Inference at Design Time via Eclipse</title>
		<link>http://eclipsesource.com/blogs/2009/08/17/eclipse-type-inference-at-design-time/</link>
		<comments>http://eclipsesource.com/blogs/2009/08/17/eclipse-type-inference-at-design-time/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 16:52:11 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[syndicate]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[implicit typing]]></category>
		<category><![CDATA[jdt]]></category>
		<category><![CDATA[type inference]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=2112</guid>
		<description><![CDATA[Dynamically typed programming languages have become more popular over the recent years. Dynamic typing makes certain tasks a lot easier, however, I will not go into a full discussion of dynamic versus static typed languages (I&#8217;m saving that discussion for later). Instead, I want to take a look at one of the cool ideas in [...]]]></description>
			<content:encoded><![CDATA[<p>Dynamically typed programming languages have become more popular over the recent years. Dynamic typing makes certain tasks a lot easier, however, I will not go into a full discussion of <em>dynamic versus static</em> typed languages (I&#8217;m saving that discussion for later). Instead, I want to take a look at one of the cool ideas in dynamic language design and demonstrate how Eclipse can somewhat emulate it.</p>
<p>By definition, dynamic languages have no concept of variable types. This means there is no need for a type declaration&#8230; so for example, in Python or Ruby you can just write:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">randomNumber=<span style="color: #ff4500;">4</span></pre></div></div>

<p>Some statically typed languages also allow the type declaration of variables to be omitted. But since the language is statically typed, where the does the variable type come from? A reasonably smart compiler can <em>infer</em> the type of a variable by looking at how the variable is used. Haskell and Scala are two examples of such languages that allow <em>implicit typing</em> and then determine the types through <em>compile time <a href="http://en.wikipedia.org/wiki/Type_inference">type inference</a></em>. This allows you to write the following scala code:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">var</span> randomNumber<span style="color: #000080;">=</span><span style="color: #0000ff; font-weight: bold;">new</span> BigDecimal<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">4</span><span style="color: #F78811;">&#41;</span></pre></div></div>

<p>The type of <code>randomNumber</code> is <code>java.math.BigDecimal</code>. This avoids having to type <code>BigDecimal</code> twice&#8230; once for the variable type declaration and once for the constructor. Since Eclipse has a full blown Java compiler under the hood (a fairly smart one), it allows you to do almost the same. You can basically omit the type declaration altogether, and when Eclipse complains just, hit <em>Ctrl+1</em> and select the appropriate option. The official name for that shortcut is <strong>Quickfix</strong>, but I like to think of as: &#8220;Dear Eclipse, I&#8217;m just too lazy, <a href="http://en.wikipedia.org/wiki/DWIM">why don&#8217;t you fix it for me</a>?&#8221;</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2009/08/design-time-type-inference.png"><img class="alignnone size-medium wp-image-2710" title="Eclipse design time type inference" src="http://eclipsesource.com/blogs/wp-content/uploads/2009/08/design-time-type-inference-300x108.png" alt="design time type inference 300x108 Type Inference at Design Time via Eclipse" width="300" height="108" /></a></p>
<p>I don&#8217;t know whether this quickfix was created with this usage pattern in mind, but I find myself using this quite often. A close relative is the <strong>Extract variable</strong> refactoring which also does design time type inference. Another refactoring where type inference comes into play is <strong>Generalize declared type</strong>, which lets you reduce the specificness of a variable type to its lowest common denominator.</p>
<p>I am sure there are a number of similar refactorings and quick fixes. These powerful features demonstrate how a smart IDE can make working with a statically typed language much easier, while still reaping the benefits of static type checks.</p>
<p>What are your favorite type inference shortcuts?</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/08/17/eclipse-type-inference-at-design-time/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tip: Project Level Settings</title>
		<link>http://eclipsesource.com/blogs/2008/09/09/tip-project-level-settings/</link>
		<comments>http://eclipsesource.com/blogs/2008/09/09/tip-project-level-settings/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 14:51:47 +0000</pubDate>
		<dc:creator>Chris Aniszczyk</dc:creator>
				<category><![CDATA[syndicate]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[jdt]]></category>
		<category><![CDATA[pde]]></category>

		<guid isPermaLink="false">http://code9.com/?p=66</guid>
		<description><![CDATA[I can&#8217;t count how many times I have come across developers that aren&#8217;t using project level settings. It makes me a bit sad in the beginning, but once I show people what you can do with project level settings, I&#8217;m immediately filled with glee. Why should you use project level settings? The main reason is [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t count how many times I have come across developers that aren&#8217;t using project level settings. It makes me a bit sad in the beginning, but once I show people what you can do with project level settings, I&#8217;m immediately filled with glee. Why should you use project level settings? The main reason is that you can enforce these settings all across your team (they are shareable) and even contributors to your project. Here are some examples of what I mean:</p>
<p><strong>Java Settings</strong></p>
<p>I recall being at a client site doing some code review&#8230; when people all the sudden started bickering about if &#8216;if&#8217; statements should always be closed or not and where the &#8216;{&#8216; should go. It happened that each team member had their styles that were different from what the team lead wanted. A part of me wanted to see how long the argument would go on for&#8230; but I decided instead to show them the excellent formatter options provided by JDT:</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2008/09/formatter-control.png"><img src="http://eclipsesource.com/blogs/wp-content/uploads/2008/09/formatter-control-300x215.png" alt="formatter control 300x215 Tip: Project Level Settings" title="formatter-control" width="300" height="215" class="alignnone size-medium wp-image-372" /></a></p>
<p>I could see the team lead&#8217;s eyes light up when he could configure these settings on a project level basis. The ability to enforce a style he wanted his team to share can save a lot of stress. Next, I told him I even had something better up my sleeves&#8230; save actions. Why have to manually format your source when you can do it when the file is ACTUALLY SAVED? I pointed him to the &#8216;Save Actions&#8217; preference page:</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2008/09/save-actions.png"><img src="http://eclipsesource.com/blogs/wp-content/uploads/2008/09/save-actions-300x147.png" alt="save actions 300x147 Tip: Project Level Settings" title="save-actions" width="300" height="147" class="alignnone size-medium wp-image-373" /></a></p>
<p>In there, he was excited to find that you can format code on save along with organizing imports (amongst other things). However, this is only part of the story. There are a lot of other project level settings that are useful like compiler compliance settings. You can setup different projects to comply with different versions of Java depending on your needs. The point here was that you can setup a consistent level of settings to be shared by your team so when they check out the project they need to work on&#8230; they have all the settings to not conflict with the rest of their team.</p>
<p><strong>Plug-in Settings</strong></p>
<p>If you&#8217;re developing plug-ins, <a href="http://www.eclipse.org/jdt">PDE</a> provides some project level settings also. You can setup settings to flag errors if you&#8217;re missing NLS&#8217;d strings or using things like deprecated extension elements. In 3.5, you will be able to enforce versions on things like imported packages, exported packages and required bundles. Feel free to explore what you can do!</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2008/09/pde-settings.png"><img src="http://eclipsesource.com/blogs/wp-content/uploads/2008/09/pde-settings-294x300.png" alt="pde settings 294x300 Tip: Project Level Settings" title="pde-settings" width="294" height="300" class="alignnone size-medium wp-image-375" /></a></p>
<p><strong>Sharing Settings<br />
</strong></p>
<p>So now you&#8217;re thinking&#8230; how do I share these settings once I create them for one project? Do I have to manually craft settings via the preference pages for each project? The answer is no, however, the solution to share settings amongst projects isn&#8217;t very pretty. The easiest way to do this is to simply copy the &#8216;.settings&#8217; folder over from a project that was previously setup to the new project:</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2008/09/settings.png"><img src="http://eclipsesource.com/blogs/wp-content/uploads/2008/09/settings.png" alt="settings Tip: Project Level Settings" title="settings" width="292" height="218" class="alignnone size-full wp-image-376" /></a></p>
<p>This is the approach that is commonly used in some Eclipse.org projects. For example, in Equinox, the settings are available in a <a href="http://www.eclipse.org/equinox/documents/coding.php">webpage</a> for consumption. Be warned that you should only copy the preference files you need, you may be bringing some preferences you don&#8217;t want, so just becareful.</p>
<p>It&#8217;s my hope that in Eclipse 3.5, we can address some of the usability issues in sharing preferences across projects. If this issue is important to you, feel free to file a <a href="http://bugs.eclipse.org">bug</a>.</p>
<p><strong>Conclusion</strong></p>
<p>So what did we learn? Hopefully, that project level settings rock and there&#8217;s no excuse to not use them. There may be some usability quirks in sharing the settings with new projects, but that shouldn&#8217;t stop anyone in using something that can save you a ton of time.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2008/09/09/tip-project-level-settings/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

