<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Chris Patterson - Los Techies - Latest Comments</title><link xmlns="http://www.w3.org/2005/Atom" rel="http://api.friendfeed.com/2008/03#sup" href="http://disqus.com/sup/all.sup#forumcomments-a693b870" type="application/json"/><link>http://phatboyglt.disqus.com/</link><description></description><atom:link href="http://phatboyglt.disqus.com/comments.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 06 May 2013 03:30:34 -0000</lastBuildDate><item><title>Re: Implementing Routing Slip with MassTransit</title><link>http://lostechies.com/chrispatterson/2013/03/28/implementing-routing-slip-with-masstransit/#comment-886229397</link><description>&lt;p&gt;I would benefit from a meaningful problem domain as well to understand &lt;br&gt;this a little better. &lt;/p&gt;

&lt;p&gt;After a year of experimenting with mainly &lt;br&gt;NServiceBus (and a little bit of MassTransit) I am currently laying the &lt;br&gt;foundations to refactor some of our older logic to use a MessageBus. &lt;br&gt;However depending on the content of the message there will be a &lt;br&gt;different flow with some steps that are shared, others are not. &lt;/p&gt;

&lt;p&gt;All flows are cross bounded contexts and therefor my assumption is a messagebus can be of great benefit. This courier extension seems to provide something like an ad hoc workflow control in messagehandling. Did I understand the article correctly?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Guillaume Schuermans</dc:creator><pubDate>Mon, 06 May 2013 03:30:34 -0000</pubDate></item><item><title>Re: Implementing Routing Slip with MassTransit</title><link>http://lostechies.com/chrispatterson/2013/03/28/implementing-routing-slip-with-masstransit/#comment-848609636</link><description>&lt;p&gt;It will take me a few days to write it up, but yes. &lt;/p&gt;

&lt;p&gt;The domain is an end-user and support configurable solution where the tight coupling of services to events and reactions is not feasible due to the time required to change code/behavior. In a system with thousands of message flows, each of which can opt-in to and/or change the order of service invocation in which changes are effective immediately, it's not practical to require code changes to handle service orchestration.&lt;/p&gt;

&lt;p&gt;All of the routing slips are built by a router, which based on the message content selects the appropriate path through the system.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Chris Patterson</dc:creator><pubDate>Mon, 01 Apr 2013 11:58:24 -0000</pubDate></item><item><title>Re: Implementing Routing Slip with MassTransit</title><link>http://lostechies.com/chrispatterson/2013/03/28/implementing-routing-slip-with-masstransit/#comment-846402401</link><description>&lt;p&gt;Can you give a more meaningful problem domain to illustrate this? A simple sequence can be much better handled by having one service do step 1, publish an event, which goes to another service, which does step 2 and publishes another event, going on to another service, etc.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">udidahan</dc:creator><pubDate>Fri, 29 Mar 2013 15:58:24 -0000</pubDate></item><item><title>Re: Odoyule Rules Engine for .NET</title><link>http://lostechies.com/chrispatterson/2012/04/11/odoyule-rules-engine-for-net/#comment-779181741</link><description>&lt;p&gt;I downloaded the code and when I attempt to compile it, the reference for Internals.Extentions and Internals.Reflection is missing.  I have been unable to locate the assembly.  PLease advise.&lt;br&gt;Thanks.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">R Programmer</dc:creator><pubDate>Sat, 26 Jan 2013 13:51:32 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-774595004</link><description>&lt;p&gt;Did you read the comment?&lt;/p&gt;

&lt;p&gt;Firstly, if your library is being consumed by a 3rd party you can't guarantee that your best practices are being adhered to. There are bad programmers out there.&lt;br&gt;If your library is not being consumed by a 3rd party you can't guarantee that your best practices are being adhered to, especially in threaded situations. Good programmers make mistakes.Throwing an ObjectDisposedException is better than double-disposing in absolutely every situation. Rolled back that transaction twice? "Yeah, but the controlling thread was in charge of disposing that object." Try telling that to a customer who just lost millions to a bug that is easily avoided by simply not using a `bool`. At the very least it's a lot more explanatory than a FileNotFoundException in a bug report.I don't put hypothetical walls up around myself, I put up real barriers - and you are irresponsible if you don't because there is a massive difference between what you should do and what could happen.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jonathan C Dickinson</dc:creator><pubDate>Tue, 22 Jan 2013 03:50:48 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-748608290</link><description>&lt;p&gt;This is important, and this is a great tip! When I pulled down the latest ActionMailer.Net library from Nuget, I started getting StackOverflowExceptions. Turns out, they didn't implement IDisposable correctly. I created a pull-request that fixes the issue, but in retrospect, I still missed some tips brought up in this article.&lt;/p&gt;

&lt;p&gt;Thanks for sharing.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">kamranayub</dc:creator><pubDate>Thu, 27 Dec 2012 12:34:03 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-748015714</link><description>&lt;p&gt;What do you think of &lt;a href="http://dave-black.blogspot.com/2011/03/how-do-you-properly-implement.html?" rel="nofollow"&gt;http://dave-black.blogspot.com...&lt;/a&gt; I've been using it as my template&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Shmueli Englard</dc:creator><pubDate>Wed, 26 Dec 2012 15:38:36 -0000</pubDate></item><item><title>Re: Odoyule Rules Engine for .NET</title><link>http://lostechies.com/chrispatterson/2012/04/11/odoyule-rules-engine-for-net/#comment-743421989</link><description>&lt;p&gt;any sample codes i can use? newbie here.... :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jophez</dc:creator><pubDate>Thu, 20 Dec 2012 03:14:36 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-728423935</link><description>&lt;p&gt;That's awesome... hey, wait a minute...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark Lindell</dc:creator><pubDate>Wed, 05 Dec 2012 11:49:05 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-727418979</link><description>&lt;p&gt;Good article. Only thing I've noticed to other dispose advice articles I have read is that the sample implementation here sets the private _disposed field to true when disposing has done. Some other articles advices to set, and what I usually do, to set the field true right after it is checked in the beginning of protected Dispose method to prevent entering the disposing lines twice. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MasaSam</dc:creator><pubDate>Tue, 04 Dec 2012 13:40:08 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-727202035</link><description>&lt;p&gt;Hmm yeah, I agree with previous comments. The suggestion in this post is only valid when you want to dispose of unmanaged resources. I can tell you that in 6 years working with .NET, I *NEVER* had to deal with unmanaged resources from .NET.&lt;/p&gt;

&lt;p&gt;It is actually harmful to follow this recommendation if you don't have unmanaged resources because implementing a finalizer in a class automatically promotes the object to Gen 2, and you'll end up with poor GC performance.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">RaptorXP</dc:creator><pubDate>Tue, 04 Dec 2012 10:02:58 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-727169908</link><description>&lt;p&gt;If you are using any third-party library (including most of the .NET runtime, such as WCF and others) there no way you can achieve this "catch-free" system. If there is nothing the calling method can do about the exception (other than explode in a spectacular fashion) - why bother throwing the exception. Sometimes, RPC calls and the like just don't end in a happy place, and that's often just fine. Not to mention that so many people call Dispose in a catch block or finally block, without a try/catch around it, which can lead to entire application crashes.&lt;/p&gt;

&lt;p&gt;Which sucks at 2am in a production 24x7 system. Plan for failure, and deal with it in the code so you can sleep at night.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Chris Patterson</dc:creator><pubDate>Tue, 04 Dec 2012 09:26:08 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-727167115</link><description>&lt;p&gt;If multiple threads are sharing a disposable resource, a parent or other thread should be responsible for disposing of it once the consuming threads have exited. Otherwise, a thread could dispose of something that another thread might still be using.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Chris Patterson</dc:creator><pubDate>Tue, 04 Dec 2012 09:22:46 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-727163235</link><description>&lt;p&gt;Both classes have their own private _disposed, so no problem there.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Chris Patterson</dc:creator><pubDate>Tue, 04 Dec 2012 09:18:10 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-727022820</link><description>&lt;p&gt;This is a good article for beginner developpers, however you should check your example.&lt;br&gt;When explaining how a derived class should override the Dispose(bool) method, you have it set the _disposed falg to true before calling the base.Dispose, that will result in the base class not doing its dispose job and simply setting object references to null....&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">fflams</dc:creator><pubDate>Tue, 04 Dec 2012 06:03:58 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-726947288</link><description>&lt;p&gt; (I meant to say skim through part II of the article which offers some simple advice that greatly simplifies the implementation of IDisposable resources)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jer0enh</dc:creator><pubDate>Tue, 04 Dec 2012 04:13:47 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-726943430</link><description>&lt;p&gt;Of course it is, I'm not arguing with that. We need deterministic disposal and obviously in some cases the full dispose pattern as you describe it is warranted. However, implementing this full pattern by default on every class that implements IDisposable hurts readability and as others also have said, a Finalizer is almost never needed and can actually introduce other (performance) issues. Please at least skim through the article on codeproject I linked to, it's well worth a read. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jer0enh</dc:creator><pubDate>Tue, 04 Dec 2012 04:08:02 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-726879992</link><description>&lt;p&gt;Good observation (I hope!). The scary thing is that I know quite a few devs who would write that sort of code and make that sort of comments...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steve Walsh</dc:creator><pubDate>Tue, 04 Dec 2012 02:32:02 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-726692377</link><description>&lt;p&gt;Swallowing exceptions in the dispose method or finalizer is arguably more dangerous than having the application crash since it can leave your application in an undefined state. I dis-recommend against the advice given in this article. An exception should be an exception and therefore you should do all in your power for preventing Exceptions in the first place and if one is detected, build in the right control flow for preventing that exception from ever happening. Ideally, your application should have no catch blocks.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Evil Exception</dc:creator><pubDate>Mon, 03 Dec 2012 22:05:23 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-726447800</link><description>&lt;p&gt;This is scary, I pity people working with you... Continue writing vague, performance-hitting and hard-to-read code. And conveying it with such vanity...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sergey</dc:creator><pubDate>Mon, 03 Dec 2012 17:16:39 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-726397282</link><description>&lt;p&gt;"I can't believe you are seriously suggesting that someone write LESS code." I try to understand if this is sarcasm or not.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tec Goblin</dc:creator><pubDate>Mon, 03 Dec 2012 16:24:32 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-726322526</link><description>&lt;p&gt;DisposableClass and SubDisposableClass both have their own _disposed flag, so it should be fine. Glad you enjoyed the article - be sure to read all the comments as well!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Chris Patterson</dc:creator><pubDate>Mon, 03 Dec 2012 15:02:23 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-726294505</link><description>&lt;p&gt;Awesome article, details all the potential pitfalls of implementing IDisposable. I noticed a smallmistake and I wanted to point it out in case someone accidentally incorporates it in their project:SubDisposableClass.Dispose sets _disposed to true before calling the baseclass implementation of Dispose. This will result in the cleanup logic in the base class neverbeing executed (since _disposed will already be set to true).&lt;br&gt; &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Corey</dc:creator><pubDate>Mon, 03 Dec 2012 14:30:59 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-726240873</link><description>&lt;p&gt;I agree with peterritchie. Only implement the finalizer if you directly control unmanaged resources (which you should **NEVER EVER** be directly controlling anyway, see SafeHandle (&lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.safehandle.aspx" rel="nofollow"&gt;http://msdn.microsoft.com/en-u...&lt;/a&gt; ), or obscure scenarios like temporary files.&lt;/p&gt;

&lt;p&gt;The reason it is important is because of the finalizer queue (&lt;a href="http://msdn.microsoft.com/en-us/library/0s71x931.aspx" rel="nofollow"&gt;http://msdn.microsoft.com/en-u...&lt;/a&gt; ). The GC needs to iterate over this thing every time it does a pass. Filling it up with junk that doesn't need to be there isn't a good idea.However, you should always provide Dispose(bool) as your inheritors might find they need a finalizer (you don't need one because you know that you should be using SafeHandle).&lt;/p&gt;

&lt;p&gt;Your code is also susceptible to a race condition, you could be double-disposed in threaded scenarios. Considering that the thread-safe code is shorter it makes more sense to always do it that way.&lt;/p&gt;

&lt;p&gt;Basically, you are looking for this: &lt;a href="https://gist.github.com/4196875" rel="nofollow"&gt;https://gist.github.com/419687...&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edit: Note that in .Net even if you are not using threads there is the 'virtual thread' that the GC imposes (the GC can interrupt your code wherever it pleases), even if there wasn't a finalizer thread. This means that if you don't use the interlocked route you are susceptible to double-dispose.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jonathan C Dickinson</dc:creator><pubDate>Mon, 03 Dec 2012 13:24:18 -0000</pubDate></item><item><title>Re: IDisposable, Done Right</title><link>http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/#comment-725463663</link><description>&lt;p&gt;I think you might have been lured by a troll.  AstroArch, as in Astronaut Architect?  I think AstroArch is having a joke of it.  Kind of funny, IMO, assuming it is a joke.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Hmmm</dc:creator><pubDate>Sun, 02 Dec 2012 12:07:20 -0000</pubDate></item></channel></rss>