<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.simple-talk.com/community/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>Jason Crease</title><link>http://www.simple-talk.com/community/blogs/jcrease/default.aspx</link><description>Test Engineer - Red Gate Software</description><dc:language>en-US</dc:language><generator>CommunityServer 2.0 (Debug Build: 60217.2664)</generator><item><title>Testing the speed of ANTS Profiler 4</title><link>http://www.simple-talk.com/community/blogs/jcrease/archive/2008/09/16/69546.aspx</link><pubDate>Tue, 16 Sep 2008 19:55:00 GMT</pubDate><guid isPermaLink="false">f46e5dea-70cd-4a69-a7e1-fd07a313bd4d:69546</guid><dc:creator>Jason Crease</dc:creator><slash:comments>0</slash:comments><comments>http://www.simple-talk.com/community/blogs/jcrease/comments/69546.aspx</comments><wfw:commentRss>http://www.simple-talk.com/community/blogs/jcrease/commentrss.aspx?PostID=69546</wfw:commentRss><description>&lt;P&gt;Profiling and debugging code inevitably adds overhead, and I know that it can be really frustrating. The overhead can either be small, e.g. the Visual Studio debugger, or massive, as with most performance profilers. A developer may invest in a performance profiler to optimize an algorithm that takes 10 minutes to run, and finds that when profiled it takes 2 hours to run. A top priority in the development of ANTS Profiler 4 was to make it faster than its predecessor and faster than any other profiler on the market.&lt;/P&gt;
&lt;P&gt;We have found ANTS Profiler 4 to be about eight times faster than its predecessor, ANTS Profiler 3. It is also 4 to 20 times faster at line-level profiling than other profilers on the market.&lt;/P&gt;
&lt;P&gt;I did a few speed tests and I have made a video to show how ANTS Profiler 4 compares to the fastest-known other profiler: &lt;/P&gt;
&lt;P&gt;&lt;A href="/blogbits/Jason_Crease/ANTS4/ANTS4_vs_Competitor/ANTS4_vs_Competitor.html" target=_blank&gt;ANTS Profiler 4 vs fastest known competitor&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Here it is compared to ANTS Profiler 3: &lt;/P&gt;
&lt;P&gt;&lt;A href="/blogbits/Jason_Crease/ANTS4/ANTS4_vs_ANTS3/ANTS4_vs_ANTS3.html" target=_blank&gt;ANTS Profiler 4 vs ANTS Profiler 3&lt;/A&gt; &lt;/P&gt;If you want to try out ANTS Profiler 4, you can download it from the &lt;A href="http://www.red-gate.com/products/ants_profiler/index.htm?utm_source=simpletalk&amp;amp;utm_medium=blog&amp;amp;utm_content=jason-testingspeedap4&amp;amp;utm_campaign=antsprofiler" target=_blank&gt;RedGate website&lt;/A&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=69546" width="1" height="1"&gt;</description></item><item><title>A Quick .NET Puzzle</title><link>http://www.simple-talk.com/community/blogs/jcrease/archive/2008/07/17/62701.aspx</link><pubDate>Thu, 17 Jul 2008 23:17:00 GMT</pubDate><guid isPermaLink="false">f46e5dea-70cd-4a69-a7e1-fd07a313bd4d:62701</guid><dc:creator>Jason Crease</dc:creator><slash:comments>3</slash:comments><comments>http://www.simple-talk.com/community/blogs/jcrease/comments/62701.aspx</comments><wfw:commentRss>http://www.simple-talk.com/community/blogs/jcrease/commentrss.aspx?PostID=62701</wfw:commentRss><description>&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN&gt;&lt;FONT face=Arial&gt;Just&amp;nbsp;a quick&amp;nbsp;.NET puzzle.&amp;nbsp; Does this application ever throw that ApplicationException?&amp;nbsp; If so, why?&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;&lt;FONT face=Arial&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;using &lt;/SPAN&gt;&lt;SPAN&gt;System&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;using &lt;/SPAN&gt;&lt;SPAN&gt;System.Threading&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;class &lt;/SPAN&gt;&lt;SPAN&gt;Program&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;static long &lt;/SPAN&gt;&lt;SPAN&gt;Num &lt;/SPAN&gt;&lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;static void &lt;/SPAN&gt;&lt;SPAN&gt;Main&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;string&lt;/SPAN&gt;&lt;SPAN&gt;[] args&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Thread t1 &lt;/SPAN&gt;&lt;SPAN&gt;= new &lt;/SPAN&gt;&lt;SPAN&gt;Thread&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ModifyNum&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;t1.Start&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;while &lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;long &lt;/SPAN&gt;&lt;SPAN&gt;k &lt;/SPAN&gt;&lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;Num&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;k &lt;/SPAN&gt;&lt;SPAN&gt;!= -&lt;/SPAN&gt;&lt;SPAN&gt;1&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN&gt;k &lt;/SPAN&gt;&lt;SPAN&gt;!= &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;throw new &lt;/SPAN&gt;&lt;SPAN&gt;ApplicationException&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"k is not -1 or 0.&amp;nbsp;&amp;nbsp;It is " &lt;/SPAN&gt;&lt;SPAN&gt;+ &lt;/SPAN&gt;&lt;SPAN&gt;k.ToString&lt;/SPAN&gt;&lt;SPAN&gt;());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;static void &lt;/SPAN&gt;&lt;SPAN&gt;ModifyNum&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while &lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Num &lt;/SPAN&gt;&lt;SPAN&gt;== &lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;Num &lt;/SPAN&gt;&lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;else &lt;/SPAN&gt;&lt;SPAN&gt;Num &lt;/SPAN&gt;&lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;}&lt;BR&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;&lt;FONT face=Arial&gt;Stuck?&amp;nbsp; Then h&lt;SPAN&gt;ere's a hint: if you change&amp;nbsp;Num from a long to an int, it never throws the exception.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=62701" width="1" height="1"&gt;</description></item><item><title>ANTS Performance Profiler 4 = Sexy Software!?</title><link>http://www.simple-talk.com/community/blogs/jcrease/archive/2008/06/03/58172.aspx</link><pubDate>Tue, 03 Jun 2008 22:46:00 GMT</pubDate><guid isPermaLink="false">f46e5dea-70cd-4a69-a7e1-fd07a313bd4d:58172</guid><dc:creator>Jason Crease</dc:creator><slash:comments>2</slash:comments><comments>http://www.simple-talk.com/community/blogs/jcrease/comments/58172.aspx</comments><wfw:commentRss>http://www.simple-talk.com/community/blogs/jcrease/commentrss.aspx?PostID=58172</wfw:commentRss><description>&lt;P&gt;I sit next to this guy called Stephen Chambers. He is the Usability Engineer working on our next version of our code profiler, ANTS Performance Profiler 4. He is completely revising the UI of ANTS Profiler, and spends most of his time phoning developers asking what they would like to see in the next version, and then designing the new UI based on the feedback he gets.&lt;/P&gt;
&lt;P&gt;Occasionally, you’ll hear some outbursts such as: “It’s getting hotter and hotter round heeere!” If you ask him what he’s on about, he’ll reply in an apologetic tone, “I can’t help it…. It really is very sexy!” That’s when I realise he’s talking about ANTS Performance Profiler 4 (APP 4) and the new design he’s working on. He’s contemplating the slick interface and clean lines of the profiler, summoning passers-by to come and check out “How god damn sexy it looks!”&lt;/P&gt;
&lt;P&gt;So, the other day I asked for more detail. What exactly makes Stephen so animated? &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1. One-click profiling&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;He loves the one-click profiling concept. He spent a lot of time working on the opening dialog. No 52-step wizards - just a single screen. The opening dialog is implemented to allow immediate profiling. That way, users will be more inclined to use the tool a lot more frequently, because it’s so quick and easy. &lt;/P&gt;
&lt;P&gt;&lt;IMG src="/blogbits/tonyd/Jcrease//SexyPANTS_image001.jpg"&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Figure 1: Opening Dialog of ANTS Performance Profiler 4&lt;/EM&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2. Much greater control for the user&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;The decision to remove the concept of ‘snapshots’ has produced an entirely new way of interacting with the profiler. Why confine the user to ‘snapshots’ when he could just choose any arbitrary period of time? Simply highlight any period of time (e.g. the creation of a Form), and see profiling results for that period. &lt;/P&gt;
&lt;P&gt;&lt;IMG src="/blogbits/tonyd/Jcrease//SexyPANTS_image002.jpg"&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Figure 2: Timeline feature in ANTS Performance Profiler 4&lt;/EM&gt; &lt;/P&gt;
&lt;P&gt;With snapshots, you must remember to switch back to the profiler to take a snapshot, reset results, etc. The need to switch from a task to the profiler has now been removed. The user can perform any number of actions they wish and retrospectively analyze the performance of each task in as much depth as they wish. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;3. Responsiveness of the interface&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;Stephen has so far organised over 15 hours of testing sessions with users of the Early Access Program of APP 4. I asked him about their feedback. It seems that participants to the usability sessions have been stunned by the speed at which the results for a given region are processed and displayed. This can equally be done while the profiled application is running or after it has exited. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;4. Clear and simple interface&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;Given the inherent complications of performance profiling, creating a front end that keeps things simple and immediate was a priority for Stephen. The UI went through several iterations and one of the main achievements of the APP 4 development team has been the reduction of options and windows on the main UI. Stephen seems to be getting a satisfying feeling watching a participant in a feedback session of APP 4 install it, set-up a project to be profiled and locate a performance bottleneck within minutes. The power of the profiler is as it should be – hidden under the surface with just the right number of options at the right time to give the user the power to examine the data in any way they feel like. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;5. Not throwing the baby out with the bathwater&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;Talking to existing users of ANTS Profiler 3 revealed a huge amount about not only what features people would like to see in a new version but also what they really liked about the existing version. ANTS Profiler is well-known for its slick line-level timings feature, and some were concerned a new versions may present a ‘change for the worse’. APP 4 represents innovation in many areas, but preserves the features that people found genuinely useful in ANTS Profiler 3. We originally considered dropping the ‘All Methods Grid’, but this decision was quickly reversed upon talking to customers. Instead of a removal or total re-design, a number of subtle tweaks were made to simply freshen up its appearance and extend its usefulness. For example performance bars were added to heighten the visibility of poorly performing methods. 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="/blogbits/tonyd/Jcrease//SexyPANTS_image003.jpg"&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Figure 3: The fresher ‘All Methods’ grid in ANTS Performance Profiler 4&lt;/EM&gt; &lt;/P&gt;
&lt;P&gt;The code view has retained the iconic &lt;A href="http://www.red-gate.com/products/ants_profiler/index.htm" target=_blank&gt;ANTS Profiler 3&lt;/A&gt; red bars but we have tweaked its functionality by showing the currently selected method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find Stephen’s passion for his work impressive. He gets amazing satisfaction from watching users understand the features and options available, and listening to users saying “oh wow, that’s what I call a responsive profiler!” or “very clean interface!” Admittedly, a lot of work went into these things, so I guess, I can understand that…but I can’t help feeling a little uneasy when I see Stephen dancing on his chair, singing “ANTS Performance Profiler, Sexy Software…”! &lt;/P&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=58172" width="1" height="1"&gt;</description></item><item><title>Order of Construction</title><link>http://www.simple-talk.com/community/blogs/jcrease/archive/2008/06/02/57964.aspx</link><pubDate>Mon, 02 Jun 2008 21:05:00 GMT</pubDate><guid isPermaLink="false">f46e5dea-70cd-4a69-a7e1-fd07a313bd4d:57964</guid><dc:creator>Jason Crease</dc:creator><slash:comments>3</slash:comments><comments>http://www.simple-talk.com/community/blogs/jcrease/comments/57964.aspx</comments><wfw:commentRss>http://www.simple-talk.com/community/blogs/jcrease/commentrss.aspx?PostID=57964</wfw:commentRss><description>&lt;P class=MsoNormal&gt;&lt;B&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;For me, inheritance is often a headache.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In particular, in what order is everything initialized?&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Consider this short C# program. &lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;It creates an instance of &lt;SPAN&gt;Dog&lt;/SPAN&gt;, which derives from &lt;SPAN&gt;Animal&lt;/SPAN&gt;.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Both &lt;SPAN&gt;Dog&lt;/SPAN&gt; and &lt;SPAN&gt;Animal&lt;/SPAN&gt; have an instance constructor, a class initializer (aka a static constructor), an instance variable, and a static variable.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=blue&gt;using&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;System&lt;/FONT&gt;&lt;FONT color=gray&gt;;
&lt;BR&gt;
&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;namespace&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;CtorOrder
&lt;BR&gt;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;class&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Animal
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;public&amp;nbsp;int&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;instanceAnimal&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;=&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Program.Print&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=darkred&gt;"Animal.instanceAnimal"&lt;/FONT&gt;&lt;FONT color=gray&gt;);
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;public&amp;nbsp;static&amp;nbsp;int&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;staticAnimal&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;=&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Program.Print&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=darkred&gt;"Animal.staticAnimal"&lt;/FONT&gt;&lt;FONT color=gray&gt;);&lt;/FONT&gt;&lt;FONT color=gray&gt;
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;public&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Animal&lt;/FONT&gt;&lt;FONT color=gray&gt;()
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=darkred&gt;"Animal&amp;nbsp;constructor"&lt;/FONT&gt;&lt;FONT color=gray&gt;);
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;}
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;static&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Animal&lt;/FONT&gt;&lt;FONT color=gray&gt;()
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=darkred&gt;"Animal&amp;nbsp;class&amp;nbsp;constructor"&lt;/FONT&gt;&lt;FONT color=gray&gt;);
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;}
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;class&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Dog&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=gray&gt;:&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Animal
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;public&amp;nbsp;int&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;instanceDog&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;=&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Program.Print&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=darkred&gt;"Dog.instanceDog"&lt;/FONT&gt;&lt;FONT color=gray&gt;);
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;public&amp;nbsp;static&amp;nbsp;int&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;staticDog&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;=&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Program.Print&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=darkred&gt;"Dog.staticDog"&lt;/FONT&gt;&lt;FONT color=gray&gt;);
&lt;BR&gt;&amp;nbsp;
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;public&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Dog&lt;/FONT&gt;&lt;FONT color=gray&gt;()
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=darkred&gt;"Dog&amp;nbsp;constructor"&lt;/FONT&gt;&lt;FONT color=gray&gt;);
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;}
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;static&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Dog&lt;/FONT&gt;&lt;FONT color=gray&gt;()
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=darkred&gt;"Dog&amp;nbsp;class&amp;nbsp;constructor"&lt;/FONT&gt;&lt;FONT color=gray&gt;);
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;}
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;BR&gt;&amp;nbsp;
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;class&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Program
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;public&amp;nbsp;static&amp;nbsp;int&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Print&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=blue&gt;string&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;s&lt;/FONT&gt;&lt;FONT color=gray&gt;)
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=black&gt;s&lt;/FONT&gt;&lt;FONT color=gray&gt;);
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;return&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;0&lt;/FONT&gt;&lt;FONT color=gray&gt;;
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;}
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;static&amp;nbsp;void&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Main&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=blue&gt;string&lt;/FONT&gt;&lt;FONT color=black&gt;[]&amp;nbsp;args&lt;/FONT&gt;&lt;FONT color=gray&gt;)
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;{
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dog&amp;nbsp;d&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;=&amp;nbsp;new&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Dog&lt;/FONT&gt;&lt;FONT color=gray&gt;();
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Console.WriteLine&lt;/FONT&gt;&lt;FONT color=gray&gt;(&lt;/FONT&gt;&lt;FONT color=darkred&gt;"\nPress&amp;nbsp;enter&amp;nbsp;to&amp;nbsp;continue"&lt;/FONT&gt;&lt;FONT color=gray&gt;);
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;Console.ReadLine&lt;/FONT&gt;&lt;FONT color=gray&gt;();
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=black&gt;}
&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;BR&gt;}&lt;/FONT&gt;&lt;FONT color=black&gt;
&lt;BR&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P class=MsoNormal&gt;There are eight activities here: &lt;/P&gt;
&lt;OL&gt;
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Dog&lt;/SPAN&gt; instance constructor 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Dog&lt;/SPAN&gt; class constructor 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Dog&lt;/SPAN&gt; instance variable 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Dog&lt;/SPAN&gt; static variable 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Animal&lt;/SPAN&gt; instance constructor 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Animal&lt;/SPAN&gt; class constructor 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Animal&lt;/SPAN&gt; instance variable 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Animal&lt;/SPAN&gt; static variable&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal&gt;The question is: ‘In what order are the eight activities run?’&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Try working it out.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Anyway, the answer is:&lt;/P&gt;
&lt;OL&gt;
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Dog&lt;/SPAN&gt; static variable 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Dog&lt;/SPAN&gt; class constructor 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Dog&lt;/SPAN&gt; instance variable 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Animal&lt;/SPAN&gt; static variable 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Animal&lt;/SPAN&gt; class constructor 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Animal&lt;/SPAN&gt; instance variable 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Animal&lt;/SPAN&gt;&amp;nbsp;instance constructor 
&lt;LI class=MsoNormal&gt;&lt;SPAN&gt;Dog&lt;/SPAN&gt; instance constructor&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal&gt;There are two things I find surprising about this:&lt;/P&gt;
&lt;OL&gt;
&lt;LI class=MsoNormal&gt;Why do static constructors run from most derived class to least derived class, i.e. &lt;SPAN&gt;Dog&lt;/SPAN&gt; then &lt;SPAN&gt;Animal&lt;/SPAN&gt;? 
&lt;LI class=MsoNormal&gt;Why do instance variables get initialized before calling the parent’s instance constructor?&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal&gt;The answer to question 1 is that Dog’s class initializer has to be run since we are running Dog’s instance constructor, but &lt;EM&gt;&lt;SPAN&gt;execution of any type's class initializer method will not trigger automatic execution of any class initializer methods defined by its base type.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Indeed, why should it?&lt;/SPAN&gt;&lt;/EM&gt;&lt;I&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;The answer to question 2 is complicated.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Constructing instance fields in the most derived class first is the only way to ensure that readonly fields are initialized and then not changed.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Check out Eric Lippert’s blog for a decent explanation: &lt;A href="http://blogs.msdn.com/ericlippert/archive/2008/02/15/why-do-initializers-run-in-the-opposite-order-as-constructors-part-one.aspx"&gt;&lt;FONT color=#800080&gt;http://blogs.msdn.com/ericlippert/archive/2008/02/15/why-do-initializers-run-in-the-opposite-order-as-constructors-part-one.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=57964" width="1" height="1"&gt;</description></item><item><title>Using the Exception Hunter Command Line to find All Methods that throw a given Exception </title><link>http://www.simple-talk.com/community/blogs/jcrease/archive/2008/01/31/45719.aspx</link><pubDate>Thu, 31 Jan 2008 18:01:00 GMT</pubDate><guid isPermaLink="false">f46e5dea-70cd-4a69-a7e1-fd07a313bd4d:45719</guid><dc:creator>Jason Crease</dc:creator><slash:comments>0</slash:comments><comments>http://www.simple-talk.com/community/blogs/jcrease/comments/45719.aspx</comments><wfw:commentRss>http://www.simple-talk.com/community/blogs/jcrease/commentrss.aspx?PostID=45719</wfw:commentRss><description>&lt;P&gt;Red-Gate's new .NET tool - Exception Hunter - shows you the exceptions that can be thrown by a .NET method. However, many users would like to see this the other way round, i.e. pick an exception and see which methods throw that exception. We will endeavour to put this in the next version of Exception Hunter. &lt;/P&gt;
&lt;P&gt;However, for the moment this functionality is available via the Exception Hunter command line. I've recorded a 5-minute video where I demonstrate how to use the command-line to find all methods that throw IO exceptions in a simple application. Have a look... &lt;/P&gt;
&lt;P&gt;&lt;A href="/blogbits/jason_crease/Exception_Hunter_Command_Line_demo_skin.swf"&gt;http://www.simple-talk.com/blogbits/jason_crease/Exception_Hunter_Command_Line_demo_skin.swf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;To download the 14-day free-trial of the .NET Developer Bundle, which includes Exception Hunter, go to: &lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.red-gate.com/dynamic/downloads/downloadform.aspx?download=exceptionhunter"&gt;Download .NET Developer Bundle&lt;/A&gt;&lt;/P&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=45719" width="1" height="1"&gt;</description></item></channel></rss>