<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>What is Object Oriented Programming?</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/02/20/77354.aspx</link><description>In a previous blog , I said &amp;#8220; This new code is about classes (FilePath) instead of being about functions (IsUncPath(string) ). &amp;#8221; Pearls of wisdom, for sure. But what does it mean? How do you know if you're really writing OO code? Try this:</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: What is Object Oriented Programming?</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/02/20/77354.aspx#77449</link><pubDate>Sat, 21 Feb 2004 03:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:77449</guid><dc:creator>Charles Shopsin</dc:creator><description>Um, sorta. I agree with what you said, but it's important to note (as you did a little with the conditionals bit that these aren't rules, they are just hints. There are times when a switch is just what you need and oo would be a rediculous waste of time.&lt;br&gt;&lt;br&gt;For example, in an app I'm working on at work I need to convert a DBType to an SqlType. Now I could either write a class with 15 overloaded constructors (or methods, depending on if I have other things to do) or just write a method called ConvertToSqlType(DbType blah) with a switch inside.&lt;br&gt;&lt;br&gt;If I needed a mega convert all the dbtypes in the world to one another class, overloads might make sense, but it just has to do this one thing. It seems like having a page full of almost identical methods is kind of a waste...&lt;br&gt;&lt;br&gt;And yeah, I know that I could just set the type of an SqlParameter and then let it convert it, but that scares me because there is no explicit guarantee that it's going to work if there is no data in there. Not to mention the fact that if you look at the code in SqlParameter (using reflector or some such tool) you'll notice that a switch is exactly what they use.</description></item><item><title>re: What is Object Oriented Programming?</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/02/20/77354.aspx#77534</link><pubDate>Sat, 21 Feb 2004 09:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:77534</guid><dc:creator>RichB</dc:creator><description>For the same reason that switch is non-OO, so is enum.</description></item><item><title>re: What is Object Oriented Programming?</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/02/20/77354.aspx#77536</link><pubDate>Sat, 21 Feb 2004 09:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:77536</guid><dc:creator>RichB</dc:creator><description>Charles, I find that I need to use switch on values returned from components written by 3rd parties (including BCL components). This is because the 3rd party components aren't written with the domain knowledge/use cases I require.&lt;br&gt;&lt;br&gt;But I can completely remove any code which switches on data private to my component and replace this with polymorphism.&lt;br&gt;&lt;br&gt;</description></item><item><title>re: What is Object Oriented Programming?</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/02/20/77354.aspx#77839</link><pubDate>Sun, 22 Feb 2004 09:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:77839</guid><dc:creator>Iain</dc:creator><description>I definitely agree with you on the exceptions thing, but it really annoys me that c# makes defining new exceptions harder than it could be (see &lt;a target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp08162001.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp08162001.asp&lt;/a&gt; for how to define a fully-capable exception). This really annoys me, because it increases the amount of stuff to do in order to have a good set of exceptions. I think python shines here, you just say stuff like:&lt;br&gt;&lt;br&gt;class ThingoException(Exception):&lt;br&gt;  pass&lt;br&gt;&lt;br&gt;class ThingoDatabaseException(ThingoException):&lt;br&gt;  pass&lt;br&gt;&lt;br&gt;class ThingoDatabaseUnavailableException(ThingoDatabaseException):&lt;br&gt;  pass&lt;br&gt;&lt;br&gt;class ThingoDatabaseIntegrityException(ThingoDatabaseException):&lt;br&gt;  pass&lt;br&gt;&lt;br&gt;and then you can catch the exceptions you care about, and it takes under 5 seconds to define yourself a new exception.&lt;br&gt;&lt;br&gt;Hopefully code templates stuff in whidbey will improve this, at least to an extent.</description></item><item><title>re: What is Object Oriented Programming?</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/02/20/77354.aspx#78401</link><pubDate>Mon, 23 Feb 2004 16:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:78401</guid><dc:creator>Kris</dc:creator><description>Enums are definitely a source of bad smells quite often.    A great refactoring is to apply &amp;quot;replace type with class&amp;quot;, etc.  Seeing code that acts conditionally on the enum outside of the type owning that enum member is a great indicator.&lt;br&gt;&lt;br&gt;</description></item><item><title>re: What is Object Oriented Programming?</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/02/20/77354.aspx#78455</link><pubDate>Mon, 23 Feb 2004 17:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:78455</guid><dc:creator>Jay Bazuzi [MS]</dc:creator><description>Kris: Here's that refactoring: &lt;a target="_new" href="http://www.refactoring.com/catalog/replaceTypeCodeWithClass.html"&gt;http://www.refactoring.com/catalog/replaceTypeCodeWithClass.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;Maybe another guideline for you is &amp;quot;enums should always be nested types&amp;quot;, since you indicate the owning type is important.&lt;br&gt;&lt;br&gt;Iain: For Whidbey I've written a template specifically for implementing an Exception, following those guidelines.  However, in my experiences I've never needed all the facilities I end up building that way.  Maybe I'm just doing it wrong.</description></item><item><title>savagevines.com &amp;raquo; Refactoring</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/02/20/77354.aspx#83396</link><pubDate>Wed, 03 Mar 2004 22:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:83396</guid><dc:creator>TrackBack</dc:creator><description>savagevines.com &amp;amp;raquo; Refactoring</description></item><item><title>re: What is Object Oriented Programming?</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/02/20/77354.aspx#101647</link><pubDate>Mon, 29 Mar 2004 23:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:101647</guid><dc:creator>Jay Bazuzi [MS]</dc:creator><description>Yeah, that is a little off-topic.  You might try asking on a C# newsgroup or a discussion board on gotdotnet.com.&lt;br&gt;</description></item></channel></rss>