<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Quick Tip: Avoid Enums If Possible</title>
	<atom:link href="http://www.hackification.com/2009/12/01/quick-tip-avoid-enums-if-possible/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackification.com/2009/12/01/quick-tip-avoid-enums-if-possible/</link>
	<description></description>
	<lastBuildDate>Fri, 23 Jul 2010 14:53:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: sil-chan</title>
		<link>http://www.hackification.com/2009/12/01/quick-tip-avoid-enums-if-possible/comment-page-1/#comment-465</link>
		<dc:creator>sil-chan</dc:creator>
		<pubDate>Mon, 11 Jan 2010 19:56:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=330#comment-465</guid>
		<description>This is all dependent on what you want to be easy and what you want to be hard (with easy and hard referring to the amount of work needed to extend the system at a later date).

Using the enumeration (a data structure), writing new functions based on it require no extra effort to refactor existing functions while adding a new operation requires an effort to update every function that relies on it to include the new case.  Therefore: with data structures, new methods = easy, new components = hard.

Using an abstract class (an object), all classes that derive from it must implement the abstract methods defined in the class.  You can add components at will without modifying sub-classes.  However, to add a new abstract method would require refactoring every existing subclass to implement the new abstract method.  Therefore: with objects, new methods = hard, new components = easy.</description>
		<content:encoded><![CDATA[<p>This is all dependent on what you want to be easy and what you want to be hard (with easy and hard referring to the amount of work needed to extend the system at a later date).</p>
<p>Using the enumeration (a data structure), writing new functions based on it require no extra effort to refactor existing functions while adding a new operation requires an effort to update every function that relies on it to include the new case.  Therefore: with data structures, new methods = easy, new components = hard.</p>
<p>Using an abstract class (an object), all classes that derive from it must implement the abstract methods defined in the class.  You can add components at will without modifying sub-classes.  However, to add a new abstract method would require refactoring every existing subclass to implement the new abstract method.  Therefore: with objects, new methods = hard, new components = easy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Allen</title>
		<link>http://www.hackification.com/2009/12/01/quick-tip-avoid-enums-if-possible/comment-page-1/#comment-464</link>
		<dc:creator>Jonathan Allen</dc:creator>
		<pubDate>Tue, 01 Dec 2009 22:23:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=330#comment-464</guid>
		<description>&gt; Notice how it’s spread all over the place. Switch statements might group by operation, but they split by concept – and that’s the exact opposite of what’s usually intended with OO coding.

C# isn&#039;t really an OO language, it lost that claim the day they added events. For real OO, look to Java and cringe.</description>
		<content:encoded><![CDATA[<p>&gt; Notice how it’s spread all over the place. Switch statements might group by operation, but they split by concept – and that’s the exact opposite of what’s usually intended with OO coding.</p>
<p>C# isn&#8217;t really an OO language, it lost that claim the day they added events. For real OO, look to Java and cringe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Allen</title>
		<link>http://www.hackification.com/2009/12/01/quick-tip-avoid-enums-if-possible/comment-page-1/#comment-463</link>
		<dc:creator>Jonathan Allen</dc:creator>
		<pubDate>Tue, 01 Dec 2009 22:18:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackification.com/?p=330#comment-463</guid>
		<description>By doing that you have lost the ability for clients to easily consume your API. Since they can&#039;t add new methods to your class directly, they still have have to use switch-like constructs. Only they can&#039;t use switch itself, they have to instead chain a series of if-else-if blocks.

Consider, for example, the DayOfWeek enumeration. There is no way you are goign to predict what uses a developer may have for that enumeration.

Long term, our static analysis tools are getting better. You could write an FxCop to check for missing switch cases, something that would be impossible with if-else-if blocks.

That said, enumerations aren&#039;t always the bees knees. For the example you gave, using classes does make sense as there isn&#039;t a finite number of operators.</description>
		<content:encoded><![CDATA[<p>By doing that you have lost the ability for clients to easily consume your API. Since they can&#8217;t add new methods to your class directly, they still have have to use switch-like constructs. Only they can&#8217;t use switch itself, they have to instead chain a series of if-else-if blocks.</p>
<p>Consider, for example, the DayOfWeek enumeration. There is no way you are goign to predict what uses a developer may have for that enumeration.</p>
<p>Long term, our static analysis tools are getting better. You could write an FxCop to check for missing switch cases, something that would be impossible with if-else-if blocks.</p>
<p>That said, enumerations aren&#8217;t always the bees knees. For the example you gave, using classes does make sense as there isn&#8217;t a finite number of operators.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
