<?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>Christophe Herreman &#187; IntelliJ IDEA</title>
	<atom:link href="http://www.herrodius.com/blog/category/intellij-idea/feed" rel="self" type="application/rss+xml" />
	<link>http://www.herrodius.com/blog</link>
	<description>Thoughts from a software developer</description>
	<lastBuildDate>Thu, 10 Jun 2010 19:08:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Marking Deprecated Classes and Methods in Flex</title>
		<link>http://www.herrodius.com/blog/190</link>
		<comments>http://www.herrodius.com/blog/190#comments</comments>
		<pubDate>Sat, 12 Sep 2009 09:40:49 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=190</guid>
		<description><![CDATA[A feature of the Flex SDK is that you can mark deprecated classes and methods via the [Deprecated] metadata tag. The goal of deprecating code is to inform developers that code will disappear in an upcoming release of a library or framework. Developers can then change their code to use the appropriate replacement and prevent [...]]]></description>
			<content:encoded><![CDATA[<p>A feature of the Flex SDK is that you can mark deprecated classes and methods via the [Deprecated] metadata tag. The goal of deprecating code is to inform developers that code will disappear in an upcoming release of a library or framework. Developers can then change their code to use the appropriate replacement and prevent problems when upgrading to newer versions. For more info, read <a href="http://java.sun.com/j2se/1.4.2/docs/guide/misc/deprecation/deprecation.html">How and When to Deprecate APIs</a>.</p>
<blockquote><p>The need for deprecation comes about because, as a class evolves, its API changes. Methods are renamed for consistency. New and better methods are added. Attributes change. But making such changes introduces a problem. You need to keep the old API around until people make the transition to the new one, but you don't want developers to continue programming to the old API.</p></blockquote>
<p>Here's an example:</p>
<div class="igBar"><span id="lactionscript-3"><a href="#" onclick="javascript:showPlainTxt('actionscript-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-3">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package org.<span style="color: #006600;">as3commons</span>.<span style="color: #006600;">reflect</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#91;</span>Deprecated<span style="color: #66cc66;">&#40;</span>replacement=<span style="color: #ff0000;">"org.as3commons.lang.ClassUtils"</span>, since=<span style="color: #ff0000;">"1.1"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ClassUtils <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Deprecated<span style="color: #66cc66;">&#40;</span>replacement=<span style="color: #ff0000;">"org.as3commons.lang.ClassUtils.forInstance()"</span>, since=<span style="color: #ff0000;">"1.1"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> forInstance<span style="color: #66cc66;">&#40;</span>instance:*, applicationDomain:ApplicationDomain = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #000000; font-weight: bold;">Class</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// ... method body ommitted</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Depending on the IDE you are using, you will even get visual hints when you are using deprecated code. Here's how <a href="http://www.jetbrains.com/idea/">IntelliJ IDEA</a> supports this. (Click to enlarge)</p>
<p><a href="http://www.herrodius.com/blog/wp-content/uploads/2009/09/intellij-idea-deprecated-hint.png" target="_blank"><img src="http://www.herrodius.com/blog/wp-content/uploads/2009/09/intellij-idea-deprecated-hint.png" alt="intellij-idea-deprecated-hint" title="intellij-idea-deprecated-hint" width="630" height="220" class="alignnone size-full wp-image-192" /></a></p>
<p>Note that I'm using an early build of the upcoming version 9 of IntelliJ IDEA, codenamed "Maia", in which Flex support has significantly been improved. You can get the prereleases <a href="http://http://www.jetbrains.net/confluence/display/IDEADEV/Maia+EAP">here</a>.</p>
<p>You can also use this on other metadata tags such as Style, but in a slightly different form:</p>
<div class="igBar"><span id="lactionscript-4"><a href="#" onclick="javascript:showPlainTxt('actionscript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-4">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Style<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">"backgroundColor"</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">"uint"</span>, format=<span style="color: #ff0000;">"Color"</span>, inherit=<span style="color: #ff0000;">"no"</span>, deprecatedReplacement=<span style="color: #ff0000;">"swatchPanelStyleName"</span>, deprecatedSince=<span style="color: #ff0000;">"3.0"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>For more info on the [Deprecated] metadata tag, see the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=metadata_3.html#172179">Flex documentation</a>.</p>
<p>I haven't tested how deprecations are handled in Flex/Flash Builder and the ASDoc system. If anyone knows, don't hesitate to add extra info in the comments and I will update this post.</p>
<p><strong>Update</strong> The [Deprecated] metadata tag was posted about some time ago in <a href="http://nondocs.blogspot.com/2007/05/metadatadeprecated.html">this blogpost</a>, which made me believe it was undocumented or at least it was at the time of writing. Thanks to Bobby Parker for posting the link to the Flex 3 docs in which the metadata is clearly documented.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/190/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
