<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.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>Peter Ritchie's MVP Blog : Microsoft</title><link>http://msmvps.com/blogs/peterritchie/archive/tags/Microsoft/default.aspx</link><description>Tags: Microsoft</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>A Upcoming Pandemic of Domain Anaemia</title><link>http://msmvps.com/blogs/peterritchie/archive/2009/01/29/a-upcoming-pandemic-of-domain-anaemia.aspx</link><pubDate>Thu, 29 Jan 2009 17:10:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1666992</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1666992</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2009/01/29/a-upcoming-pandemic-of-domain-anaemia.aspx#comments</comments><description>&lt;p&gt;There&amp;#39;s a well-known anti-pattern called the anaemic domain model[1][2].&amp;nbsp; This anti-pattern basically says domain entities, chronically, have little or no behaviour (remember, object-oriented design is about attributes &lt;strong&gt;and&lt;/strong&gt; behaviour).&lt;/p&gt;
&lt;p&gt;It should be obvious that a domain model that isn&amp;#39;t truly object oriented is a domain model with a problem.&amp;nbsp; But, let&amp;#39;s look at other reasons why the Anaemic Domain Model is an anti-pattern.&amp;nbsp; Your Domain is the nexus, the essence, of your system.&lt;/p&gt;
&lt;p&gt;An anaemic domain model is basically a reporting system.&amp;nbsp; Each &amp;quot;Entity&amp;quot; becomes, essentially, a query.&amp;nbsp; This is fine, reporting systems are necessary and prevalent.&amp;nbsp; But, to shoe-horn a domain model on top of this leads away from good reporting patterns that could add value and increases complexity, needlessly.&amp;nbsp; The designers spend most of their time trying to force entities on the system, without recognizing the basic reporting nature of the system.&amp;nbsp; This usually leads to &amp;quot;reports&amp;quot; that have to pull in multiple domain &amp;quot;entities&amp;quot; to generate the report--rehydringing data into an entity (usually through some sort of ORM) with no value added.&amp;nbsp; i.e. an ORM that will manage the child-parent relationship (and either pre-load or lazy-load aggregates) doesn&amp;#39;t provide much value here.&lt;/p&gt;
&lt;p&gt;The worst case scenario with an anaemic domain model is that there really is behaviour there; but it&amp;#39;s not handled in the domain entities; it&amp;#39;s handled in a different layer.&amp;nbsp; This is a problem because this circumvents the whole point of a domain model and layering.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;One indication of anaemia is that most of the domain classes&amp;nbsp; simply contain attributes.&amp;nbsp; Anyone familiar with patterns should recognize this as a Data Transfer Object, not a Domain Entity.&amp;nbsp; There&amp;#39;s nothing wrong with DTOs, they&amp;#39;re very important in almost all systems with any sort of complexity; but they&amp;#39;re not Domain Entities.&amp;nbsp; Let&amp;#39;s be truthful, there are systems with little or no behaviour in the domain; and that&amp;#39;s not a bad thing.&amp;nbsp; Systems like this likely don&amp;#39;t need a Domain Model and may not need techniques like Domain Driven Design.&amp;nbsp; The quicker people recognize that, the quicker they can be using a more appropriate architecture and design.&amp;nbsp; In some extreme cases the anaemic-domain-entity-DTOs service other DTOs&lt;/p&gt;
&lt;p&gt;Now, where am I going with this?&amp;nbsp; Well, there&amp;#39;s been a series of guidance out of Microsoft Patterns and Practice about some application &amp;quot;patterns&amp;quot;.&lt;/p&gt;
&lt;p&gt;First, let me describe what a pattern is.&amp;nbsp; A pattern is a way of &amp;quot;documenting a solution to a design problem&amp;quot; [3].&amp;nbsp; First, for it to be a pattern, it needs to detail the problem and it&amp;#39;s context, then provide a solution.&amp;nbsp; The latest &amp;quot;patterns&amp;quot; from P&amp;amp;P do not detail the problem or a context.&amp;nbsp; They&amp;#39;re simply architectural descriptions.&lt;/p&gt;
&lt;p&gt;Now the association between the Anaemic Domain Model and the latest P&amp;amp;P guidance.&amp;nbsp; In 3 of the 5 recently publish &amp;quot;patterns&amp;quot; the following is detail is included: &amp;quot;A Domain Entity pattern is used to define business entities that contain data only.&amp;quot;&amp;nbsp; This is the very definition of an Anaemic Domain Model.&amp;nbsp; Plus, in the RIA pattern the following, contradictory, detail is included: &amp;quot;Domain entities are responsible for implementing business rules.&amp;nbsp; Entities from the domain model represent business objects that contain data and implement behavior [sic]. In other words, the business objects are responsible for implementing business operations and interacting with other business objects.&amp;quot;&lt;/p&gt;
&lt;p&gt;This is disconcerting because historically sample code and guidance from Microsoft is simply reused without thought.&amp;nbsp; This leads to poorly designed and architected applications, and the .NET community as a whole is seen as one that produces poor-quality code and design.&amp;nbsp; Without context about the problems these patterns try to solve, they will be misused&amp;mdash;likely forced upon contexts and situations where they don&amp;rsquo;t fit, simply because &amp;ldquo;they&amp;rsquo;re from Microsoft&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;[1] &lt;a href="http://www.martinfowler.com/bliki/AnemicDomainModel.html" title="MF Bliki- AnemicDomainModel"&gt;MF Bliki- AnemicDomainModel&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;[2] &lt;a href="http://en.wikipedia.org/wiki/Anemic_Domain_Model" title="Anemic Domain Model - Wikipedia, the free encyclopedia"&gt;Anemic Domain Model - Wikipedia, the free encyclopedia&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;[3] &lt;a href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)" title="Design pattern (computer science) - Wikipedia, the free encyclopedia"&gt;Design pattern (computer science) - Wikipedia, the free encyclopedia&lt;/a&gt;&lt;/p&gt;
&lt;div style="padding-right:0px;display:inline;padding-left:0px;float:none;padding-bottom:0px;margin:0px;padding-top:0px;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:18e4120a-82b3-45b3-8d5c-9449fa380fad" class="wlWriterSmartContent"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/Microsoft+Patterns+and+Practicies"&gt;Microsoft Patterns and Practicies&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Anti-patterns"&gt;Anti-patterns&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Anaemic"&gt;Anaemic&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Anemic"&gt;Anemic&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Domain+Model"&gt;Domain Model&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Microsoft"&gt;Microsoft&lt;/a&gt;&lt;/div&gt;
&lt;div style="padding-right:0px;display:inline;padding-left:0px;float:none;padding-bottom:0px;margin:0px;padding-top:0px;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:bf1c39d4-6db7-4130-b9ff-995a8a4cb99f" class="wlWriterSmartContent"&gt;del.icio.us Tags: &lt;a rel="tag" href="http://del.icio.us/popular/Microsoft+Patterns+and+Practicies"&gt;Microsoft Patterns and Practicies&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/Anti-patterns"&gt;Anti-patterns&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/Anaemic"&gt;Anaemic&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/Anemic"&gt;Anemic&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/Domain+Model"&gt;Domain Model&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align:right;margin:0px;padding:4px 0px 4px 0px;" class="wlWriterHeaderFooter"&gt;&lt;a href="http://digg.com/submit?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2009%2f01%2f29%2fa-upcoming-pandemic-of-domain-anaemia.aspx&amp;amp;title=A+Upcoming+Pandemic+of+Domain+Anaemia"&gt;&lt;img border="0" width="100" src="http://digg.com/img/badges/100x20-digg-button.png" alt="Digg This" height="20" style="border:0;" title="Digg This" /&gt;&lt;/a&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://msmvps.com/blogs/peterritchie/archive/2009/01/29/a-upcoming-pandemic-of-domain-anaemia.aspx"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://msmvps.com/blogs/peterritchie/archive/2009/01/29/a-upcoming-pandemic-of-domain-anaemia.aspx&amp;amp;bgcolor=0080C0&amp;amp;fgcolor=FFFFFF&amp;amp;border=000000&amp;amp;cbgcolor=D4E1ED&amp;amp;cfgcolor=000000" alt="DotNetKick This" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1666992" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Design_2F00_Coding+Guidance/default.aspx">Design/Coding Guidance</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Patterns/default.aspx">Patterns</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/OOD/default.aspx">OOD</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/AntiPattern/default.aspx">AntiPattern</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/DDD/default.aspx">DDD</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/ALT.NET/default.aspx">ALT.NET</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development+Practices/default.aspx">Software Development Practices</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development+Guidance/default.aspx">Software Development Guidance</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Microsoft+Patterns+and+Practices/default.aspx">Microsoft Patterns and Practices</category></item><item><title>Received Microsoft MVP Award in C# Again</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/07/02/received-microsoft-mvp-award-in-c-again.aspx</link><pubDate>Wed, 02 Jul 2008 17:49:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1639143</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1639143</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/07/02/received-microsoft-mvp-award-in-c-again.aspx#comments</comments><description>&lt;p&gt;It appears my involvement in the technical communities over the past year have caused me to be re-awarded Microsoft MVP C# for a third year.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1639143" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/MVP/default.aspx">MVP</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Microsoft/default.aspx">Microsoft</category></item><item><title>Entity Framework Petition of Vote of Non Confidence</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/06/25/entity-framework-petition-of-vote-of-non-confidence.aspx</link><pubDate>Wed, 25 Jun 2008 17:21:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1637616</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1637616</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/06/25/entity-framework-petition-of-vote-of-non-confidence.aspx#comments</comments><description>&lt;p&gt;I had intended to be happy simply being a signatory of ADO .NET Entity Framework Vote of No Confidence.&amp;nbsp; But, there&amp;#39;s people suggesting signatories of this petition are wackos or on the fringe.&lt;/p&gt;
&lt;p&gt;Do yourself a favour and read &lt;a class="" href="http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/"&gt;the petition&lt;/a&gt;.&amp;nbsp; Read what we have issues with and how we think Entity Framework (EF) can be improved to be a better product.&amp;nbsp; Read seminal material by industry leaders on entity-oriented and object-oriented application development like &lt;a class="" href="http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1214414934&amp;amp;sr=1-1"&gt;Domain Driven Design&lt;/a&gt;, and &lt;a class="" href="http://www.amazon.com/Principles-Patterns-Practices-Robert-Martin/dp/0131857258"&gt;Agile Principles, Patterns and Practices in C#&lt;/a&gt; (and the predecessor &lt;a class="" href="http://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445"&gt;Agile Software Development: Principles, Patterns&amp;nbsp;and Practices&lt;/a&gt;) and &lt;a class="" href="http://www.amazon.com/Applying-Domain-Driven-Design-Patterns-Examples/dp/0321268202/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1214415016&amp;amp;sr=1-1"&gt;Applying Domain-Driven Design and Patterns: With Examples in C# and .NET&lt;/a&gt;.&amp;nbsp; If after you have understand this information, you think being forced to use EF on a software development&amp;nbsp;team would mean it would be hard to implement generally accepted object-oriented and entity-oriented design, the sign the petition.&lt;/p&gt;
&lt;p&gt;Yes, you have the choice no to use EF; but you also have the choice to help people to not have to deal with the issues detailed in the petition simply because they were not made aware of them.&lt;/p&gt;
&lt;p&gt;And despite the naysayers&amp;nbsp;of people who think EF should improve, the ADO.NET team &lt;a class="" href="http://blogs.msdn.com/efdesign/archive/2008/06/23/transparency-in-the-design-process.aspx"&gt;is listening and agrees&lt;/a&gt;.&lt;/p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2008%2f06%2f25%2fentity-framework-petition-of-vote-of-non-confidence.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2008%2f06%2f25%2fentity-framework-petition-of-vote-of-non-confidence.aspx" border="0" /&gt;&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1637616" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Design_2F00_Coding+Guidance/default.aspx">Design/Coding Guidance</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Microsoft/default.aspx">Microsoft</category></item><item><title>Spaces or Tabs?</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/05/26/spaces-or-tabs.aspx</link><pubDate>Mon, 26 May 2008 14:25:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1627501</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1627501</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/05/26/spaces-or-tabs.aspx#comments</comments><description>&lt;p&gt;In this day and age it seems silly to get into a discussion about whether your companies coding guidelines should have a section mandating either spaces or tabs for indents.&amp;nbsp; Tabs are clearly more flexible, but I really don&amp;#39;t think it matters at all; people can easily read code that contains spaces or tabs.&lt;/p&gt;
&lt;p&gt;But, Microsoft has departed from what seems to be the rest of the world and is mandating spaces in their new Microsoft Source Analysis Tool for C#.&lt;/p&gt;
&lt;p&gt;Word is that an update will not only mandate spaces but mandate 4 for indents.&lt;/p&gt;
&lt;p&gt;Again, I don&amp;#39;t think it&amp;#39;s much of an issue; except Microsoft Source Analysis Tool for C# doesn&amp;#39;t offer a rule to mandate tabs over spaces.&amp;nbsp; They&amp;#39;re not providing a tool for organizations to use to enforce local coding guidines, but providing a tool to mandate Microsoft&amp;#39;s coding guidelines.&lt;/p&gt;
&lt;p&gt;The tool can be downloaded &lt;a class="" href="http://code.msdn.microsoft.com/sourceanalysis/Release/ProjectReleases.aspx?ReleaseId=1047"&gt;here&lt;/a&gt; and a discussion on tabs can be found &lt;a class="" href="http://code.msdn.microsoft.com/sourceanalysis/Thread/View.aspx?ThreadId=382"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2008%2f05%2f26%2fspaces-or-tabs.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2008%2f05%2f26%2fspaces-or-tabs.aspx" border="0" /&gt;&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1627501" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Design_2F00_Coding+Guidance/default.aspx">Design/Coding Guidance</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Microsoft/default.aspx">Microsoft</category></item><item><title>System.Collections classes are obsolete</title><link>http://msmvps.com/blogs/peterritchie/archive/2007/06/26/system-collections-class-are-obsolete.aspx</link><pubDate>Tue, 26 Jun 2007 16:36:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:991013</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=991013</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2007/06/26/system-collections-class-are-obsolete.aspx#comments</comments><description>&lt;p&gt;Collection classes like ArrayList, SortedList, Stack and Hashtable will shortly be obsoleted (i.e. the &lt;a class="" title="O" href="http://msdn2.microsoft.com/en-us/library/system.obsoleteattribute(VS.80).aspx"&gt;ObsoleteAttribute&lt;/a&gt; will be applied to them in upcoming .NET Framework builds).&amp;nbsp; You can start to see this in the Silverlight Alpha (i.e. the Obsolete attribute), but they will be physically unavailable in the release version.&lt;/p&gt;
&lt;p&gt;More details can be found in a recent Base Class Library Team blog entry &lt;a class="" href="http://blogs.msdn.com/bclteam/archive/2007/06/26/non-generic-collections-to-be-removed-from-silverlight-inbar-gazit.aspx"&gt;Non-Generic Collections to be Removed from Silverlight&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Even if you don&amp;#39;t plan on writing Silverlight-compatible code you should avoid using the types detailed in the BCL Teams blog because they&amp;#39;ll be obsolete in other future versions of the .NET Framework. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=991013" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Microsoft/default.aspx">Microsoft</category></item><item><title>DateTime.ToUniversalTime *Should* Throw Exceptinos.</title><link>http://msmvps.com/blogs/peterritchie/archive/2007/06/12/datetime-touniversaltime-should-throw-exceptinos.aspx</link><pubDate>Tue, 12 Jun 2007 17:25:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:958942</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=958942</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2007/06/12/datetime-touniversaltime-should-throw-exceptinos.aspx#comments</comments><description>&lt;p&gt;A recent &lt;a class="" href="http://blogs.msdn.com/bclteam/archive/2007/06/12/datetime-touniversaltime-returns-maxvalue-minvalue-on-overflow-josh-free.aspx"&gt;.NET Base Class&amp;nbsp;Library blog post&lt;/a&gt; points out that &lt;a class="" href="http://msdn2.microsoft.com/en-us/library/system.datetime.touniversaltime(vs.80).aspx"&gt;DateTime.ToUniversalTime&lt;/a&gt; does not throw an exception for overflow values.&lt;/p&gt;
&lt;p&gt;This circumvents different Microsoft-sanctioned guidelines about using exceptions for exceptional situations, error reporting guidelines, not using return codes to communicate errors (which essentially what this is), the Method/TryMethod pattern, allowing the error to propagate to a level that knows how to deal with it, etc.&lt;/p&gt;
&lt;p&gt;I would recommend having overflows handled as exceptions and the addition of a TryToUniversalTime.&amp;nbsp; If the Method/TryMethod pattern is the favoured approach to providing two methods that result in the same thing--one without exceptions--this is impossible if the &lt;em&gt;Method&lt;/em&gt; doesn&amp;#39;t throw exceptions.&amp;nbsp; i.e. you can&amp;#39;t use Method/TryMethod pattern and therefore if you provided another method to convert to universal time that &lt;strong&gt;did&lt;/strong&gt; throw&amp;nbsp;exceptions,&amp;nbsp;you&amp;#39;d be forced to implement a completely different pattern.&lt;/p&gt;
&lt;p&gt;The argument will be that ToUniversalTime can&amp;#39;t change because there&amp;#39;s code that assumes it doesn&amp;#39;t throw an exception.&amp;nbsp; I would argue that this isn&amp;#39;t a realistic case and that code that uses ToUniversalTime simply does no error checking because it can&amp;#39;t: MinValue and MaxValue are valid values you can&amp;#39;t use them to decide whether an error has occurred.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;The argument to not change a defective method because something may depend on that defect is just wrong and is used too much as a crutch to avoid not having to deal with redesigning a proper method and dealing with the consequences.&lt;/p&gt;
&lt;p&gt;This would apply equally to TimeZone.ToUniversalTime.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=958942" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Design_2F00_Coding+Guidance/default.aspx">Design/Coding Guidance</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Microsoft/default.aspx">Microsoft</category></item><item><title>Microsoft Open Source Lab</title><link>http://msmvps.com/blogs/peterritchie/archive/2007/03/16/microsoft-open-source-lab.aspx</link><pubDate>Fri, 16 Mar 2007 05:19:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:684778</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=684778</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2007/03/16/microsoft-open-source-lab.aspx#comments</comments><description>&lt;P&gt;After the the &lt;A class="" href="http://msmvps.com/blogs/peterritchie/archive/2007/03/15/microsoft-2007-mvp-global-summit.aspx"&gt;Microsoft MVP Global Summit&lt;/A&gt;, I got a chance to meet with &lt;A class="" href="http://blogs.msdn.com/saraford/"&gt;Sara Ford&lt;/A&gt; where she gave me a wonderful tour of campus.&amp;nbsp; Part of that tour was an introduction to some of the folks at &lt;A class="" href="http://port25.technet.com/"&gt;port25.com&lt;/A&gt; and a look at the open source lab.&amp;nbsp; The port 25 folks are busy building an impressive set of servers (blades,&amp;nbsp;HPC, etc) running various OSes (like many distributions of Linux and Unix, Windows Server, Compute Cluster Server, etc.) performing various tasks like interoperability tests and &lt;A class="" href="http://www.codeplex.com/"&gt;codeplex.com&lt;/A&gt; tasks.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I can't do the complexity of their installation justice--a more detailed description can be found at &lt;A href="http://port25.technet.com/archive/2006/03/31/A-Look-Inside-Microsoft_2700_s-Open-Source-Software-Lab-_2800_Part-1_2900_.aspx"&gt;http://port25.technet.com/archive/2006/03/31/A-Look-Inside-Microsoft_2700_s-Open-Source-Software-Lab-_2800_Part-1_2900_.aspx&lt;/A&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=684778" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Open+Source/default.aspx">Open Source</category></item></channel></rss>