<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Peter-John R. Lightfoot</title>
	<atom:link href="http://pj.lightfoot.cc/feed/" rel="self" type="application/rss+xml" />
	<link>http://pj.lightfoot.cc</link>
	<description>Programmer &#124; Architect &#124; Solutionist</description>
	<lastBuildDate>Thu, 08 Dec 2011 15:15:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>A base implementation of System.IDisposable</title>
		<link>http://pj.lightfoot.cc/2011/12/a-base-implementation-of-system-idisposable/</link>
		<comments>http://pj.lightfoot.cc/2011/12/a-base-implementation-of-system-idisposable/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 19:17:55 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[IDisposable]]></category>
		<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=431</guid>
		<description><![CDATA[Based on this article by Joe Duffy. (Shoutz to Mario Lionello for his collaboration on this.) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 &#8230; <a href="http://pj.lightfoot.cc/2011/12/a-base-implementation-of-system-idisposable/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Based on <a href="http://www.bluebytesoftware.com/blog/PermaLink.aspx?guid=88e62cdf-5919-4ac7-bc33-20c06ae539ae" title="Joe Duffy: Dispose, Finalization and Resource Management" target="_blank">this article by Joe Duffy</a>. <em>(Shoutz to <a href="http://www.linkedin.com/pub/mario-lionello/3a/992/9b7" title="Mario Lionello" target="_blank">Mario Lionello</a> for his collaboration on this.)</em></p>
<div class="code">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
</pre></td><td class="code"><pre class="csharp" style="font-family:Monaco, Consolas, Andale Mono, DejaVu Sans Mono, monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Threading</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> PatternExplorer <span style="color: #008000;">&#123;</span>
   <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
   <span style="color: #008080; font-style: italic;">/// Provides a base implementation of &lt;see cref=&quot;IDisposable&quot;/&gt;.</span>
   <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
   <span style="color: #008080; font-style: italic;">/// &lt;remarks&gt;</span>
   <span style="color: #008080; font-style: italic;">/// </span>
   <span style="color: #008080; font-style: italic;">/// Derived classes that need finalizers should implement the following</span>
   <span style="color: #008080; font-style: italic;">///  AND be sealed.</span>
   <span style="color: #008080; font-style: italic;">/// </span>
   <span style="color: #008080; font-style: italic;">///    /// &lt;summary&gt;</span>
   <span style="color: #008080; font-style: italic;">///    /// Finalizer.</span>
   <span style="color: #008080; font-style: italic;">///    /// &lt;/summary&gt;</span>
   <span style="color: #008080; font-style: italic;">///    ~MyClass() {</span>
   <span style="color: #008080; font-style: italic;">///       Dispose(false);</span>
   <span style="color: #008080; font-style: italic;">///    }</span>
   <span style="color: #008080; font-style: italic;">/// </span>
   <span style="color: #008080; font-style: italic;">/// Derived classes that need to protect against access of disposed state</span>
   <span style="color: #008080; font-style: italic;">///  can use the following example:</span>
   <span style="color: #008080; font-style: italic;">/// </span>
   <span style="color: #008080; font-style: italic;">///    /// &lt;summary&gt;</span>
   <span style="color: #008080; font-style: italic;">///    /// Member accessing potentially disposed state.</span>
   <span style="color: #008080; font-style: italic;">///    /// &lt;/summary&gt;</span>
   <span style="color: #008080; font-style: italic;">///    public void MyMethod() {</span>
   <span style="color: #008080; font-style: italic;">///       ThrowIfDisposed();</span>
   <span style="color: #008080; font-style: italic;">///       // ... </span>
   <span style="color: #008080; font-style: italic;">///    }</span>
   <span style="color: #008080; font-style: italic;">/// </span>
   <span style="color: #008080; font-style: italic;">/// &lt;/remarks&gt;</span>
   <span style="color: #0600FF; font-weight: bold;">public</span> abstract <span style="color: #6666cc; font-weight: bold;">class</span> Disposable <span style="color: #008000;">:</span> IDisposable <span style="color: #008000;">&#123;</span>
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// &quot;Not Disposed&quot; state.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">int</span> NOT_DISPOSED <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// &quot;Disposing&quot; state.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">int</span> DISPOSING <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// &quot;Disposed&quot; state.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">int</span> DISPOSED <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// A flag to indicate state of disposal.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">int</span> _State<span style="color: #008000;">;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// Constructor.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">protected</span> Disposable<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// &lt;c&gt;true&lt;/c&gt; if the instance has been disposed; otherwise, &lt;c&gt;false&lt;/c&gt;.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsDisposed <span style="color: #008000;">&#123;</span>
         get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> Thread<span style="color: #008000;">.</span><span style="color: #0000FF;">VolatileRead</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">ref</span> _State<span style="color: #008000;">&#41;</span> <span style="color: #008000;">!=</span> DISPOSED<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// Occurs when the instance is being disposed.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> EventHandler Disposing<span style="color: #008000;">;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// Occurs when the instance has been disposed.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> EventHandler Disposed<span style="color: #008000;">;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// Notifies listeners that the instance is being disposed.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnDisposing<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
         <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span> Disposing <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            Disposing<span style="color: #008000;">.</span><span style="color: #0000FF;">Invoke</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, EventArgs<span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
         <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// Notifies listeners that the instance has been disposed.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnDisposed<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
         <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span> Disposed <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            Disposed<span style="color: #008000;">.</span><span style="color: #0000FF;">Invoke</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, EventArgs<span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
         <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// Performs application-defined tasks associated with freeing,</span>
      <span style="color: #008080; font-style: italic;">///  releasing, or resetting resources held by the current instance.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Dispose<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
         Dispose<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
      <span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// Disposes the instance.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;disposing&quot;&gt;&lt;c&gt;true&lt;/c&gt; to indicate explicit</span>
      <span style="color: #008080; font-style: italic;">///  cleanup (i.e. &lt;see cref=&quot;IDisposable.Dispose&quot;/&gt;()), otherwise</span>
      <span style="color: #008080; font-style: italic;">///  &lt;c&gt;false&lt;/c&gt; (i.e. implicit cleanup from finalizer)&lt;/param&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> Dispose<span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">bool</span> disposing <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
         <span style="color: #008080; font-style: italic;">// if( _State == NOT_DISPOSED ) {</span>
         <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span> Interlocked<span style="color: #008000;">.</span><span style="color: #0000FF;">CompareExchange</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">ref</span> _State, 
                                             DISPOSING, 
                                             NOT_DISPOSED<span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> NOT_DISPOSED <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// _State = DISPOSING;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span> disposing <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
               <span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
                  OnDisposing<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
               <span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#123;</span>
                  <span style="color: #008080; font-style: italic;">// intentional suppression</span>
               <span style="color: #008000;">&#125;</span>
               <span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
                  DisposeManagedFields<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
               <span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#123;</span>
                  <span style="color: #008080; font-style: italic;">// intentional suppression</span>
               <span style="color: #008000;">&#125;</span>
               <span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
                  RemoveDelegates<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
               <span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#123;</span>
                  <span style="color: #008080; font-style: italic;">// intentional suppression</span>
               <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
               ReleaseUnmanagedResources<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#123;</span>
               <span style="color: #008080; font-style: italic;">// intentional suppression</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            Interlocked<span style="color: #008000;">.</span><span style="color: #0000FF;">Increment</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">ref</span> _State<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// _State = DISPOSED;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span> disposing <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
               <span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
                  GC<span style="color: #008000;">.</span><span style="color: #0000FF;">SuppressFinalize</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
               <span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#123;</span>
                  <span style="color: #008080; font-style: italic;">// intentional suppression</span>
               <span style="color: #008000;">&#125;</span>
               <span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
                  OnDisposed<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
               <span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#123;</span>
                  <span style="color: #008080; font-style: italic;">// intentional suppression</span>
               <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
         <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// When overridden in a derived class, this method should dispose</span>
      <span style="color: #008080; font-style: italic;">///  all &lt;see cref=&quot;IDisposable&quot;/&gt; fields.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> DisposeManagedFields<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// When overridden in a derived class, this method should remove</span>
      <span style="color: #008080; font-style: italic;">///  all delegate invocations and references.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> RemoveDelegates<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// When overridden in a derived class, this method should clean up</span>
      <span style="color: #008080; font-style: italic;">///  any unmanaged resources.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> ReleaseUnmanagedResources<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
      <span style="color: #008080; font-style: italic;">/// Derived classes may use this method to prevent member access</span>
      <span style="color: #008080; font-style: italic;">///  on a disposed instance.</span>
      <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
      <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> ThrowIfDisposed<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
         <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span> IsDisposed <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">throw</span> <span style="color: #008000;">new</span> ObjectDisposedException<span style="color: #008000;">&#40;</span>GetType<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">FullName</span>,
               <span style="color: #666666;">@&quot;Access to a disposed object is not allowed.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
         <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

</div>
<p>Get the code <a href="/downloads/Disposable.cs" title="Disposable.cs">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/12/a-base-implementation-of-system-idisposable/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Intro to fluency with TDD</title>
		<link>http://pj.lightfoot.cc/2011/10/intro-to-fluency-with-tdd/</link>
		<comments>http://pj.lightfoot.cc/2011/10/intro-to-fluency-with-tdd/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 19:36:27 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Tech·Ed]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Approvals]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=331</guid>
		<description><![CDATA[Info Breakout Session :: 300 (Advanced) :: Developer Practices &#8220;In this demo-filled session, you&#8217;ll learn the why, what, where, when and how of working with test-driven development using the tools provided in Visual Studio 2010. In addition to seeing &#8216;testing-in-action&#8217;, &#8230; <a href="http://pj.lightfoot.cc/2011/10/intro-to-fluency-with-tdd/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Info</h2>
<h3>Breakout Session :: 300 (Advanced) :: Developer Practices</h3>
<p><em>&#8220;In this demo-filled session, you&#8217;ll learn the why, what, where, when and how of working with test-driven development using the tools provided in Visual Studio 2010.  In addition to seeing &#8216;testing-in-action&#8217;, you&#8217;ll learn about when to use what kind of test.  You&#8217;ll learn both about using TDD with new code and in legacy situations.  Code better and discover features in Visual Studio, such as code coverage and more that will help you to be more productive.&#8221;</em></p>
<h2>Highlights</h2>
<p>The session centered around fluency in TDD, and the requirement to keep your test code of production quality (i.e. refactor where necessary, etc.) &#8211; it also introduced the &#8220;Approvals&#8221; library, as an alternative to having to assert very granular bits of state.</p>
<p>The testing cycle suggested is: Whiteboard (Requirement), English (Translation), Code (Implementation), Test (Regression) and Result (Verification) and aims to promote the notion of &#8220;Intentional Code&#8221;.</p>
<h2>Links</h2>
<ul>
<li><a href="http://approvaltests.sourceforge.net/" title="Approval Tests Library" target="_blank">Approval Tests Library</a></li>
<li><a href="http://www.develop.com/" title="Develop Mentor" target="_blank">Develop Mentor</a></li>
<li><a href="http://www.slideshare.net/lynnlangit/testdriven-development-with-visual-studio-2010" title="Slide Deck" target="_blank">Slide Deck</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/10/intro-to-fluency-with-tdd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Tests to drive the entire SDLC</title>
		<link>http://pj.lightfoot.cc/2011/10/using-tests-to-drive-the-entire-sdlc/</link>
		<comments>http://pj.lightfoot.cc/2011/10/using-tests-to-drive-the-entire-sdlc/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 19:27:07 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[ALM]]></category>
		<category><![CDATA[Tech·Ed]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=329</guid>
		<description><![CDATA[Info Breakout Session :: 300 (Advanced) :: Developer Practices &#8220;Given that you want to deliver high quality code, when you drive your entire software development lifecycle with tests – you will dramatically improve overall quality. Microsoft’s introduction of Visual Studio &#8230; <a href="http://pj.lightfoot.cc/2011/10/using-tests-to-drive-the-entire-sdlc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Info</h2>
<h3>Breakout Session :: 300 (Advanced) :: Developer Practices</h3>
<p><em>&#8220;Given that you want to deliver high quality code, when you drive your entire software development lifecycle with tests – you will dramatically improve overall quality. Microsoft’s introduction of Visual Studio 2010 and Microsoft Test Manager provides very powerful tools we can use to begin with tests. In this presentation we specify an entire system with tests. We begin with tests to ensure the business value of an application is testable and we know when we’re done. Using those tests, we clarify the requirements using acceptance criteria expressed as test cases. Finally, we decompose the requirements to specific testable behaviours that will drive our unit tests. Armed with the complete understanding of the application, we begin to work upwards again. We automate the unit tests to ensure our code is tested. Then, as our code begins to take shape, we automate the functional tests to ensure our requirements are met – and stay met as our code continues to evolve. Finally, we automate the system and integration tests to prove to our customers that we have met the end-to-end vision of the application. The final demonstration shows the integration of all tests running during an automated nightly build.&#8221;</em></p>
<p><a href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV350" title="Video" target="_blank">Video</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/10/using-tests-to-drive-the-entire-sdlc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Async Calls in Silverlight and WPF Clients</title>
		<link>http://pj.lightfoot.cc/2011/10/async-calls-in-silverlight-and-wpf-clients/</link>
		<comments>http://pj.lightfoot.cc/2011/10/async-calls-in-silverlight-and-wpf-clients/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 19:26:04 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[Asynchrony]]></category>
		<category><![CDATA[Tech·Ed]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=327</guid>
		<description><![CDATA[Info Breakout Session :: 400 (Expert) :: Developer Tools, Languages and Frameworks &#8220;Whenever doing blocking tasks, particularly service calls in a Silverlight or Windows Presentation Foundation (WPF) client, you will need to make those calls asynchronously. While async calls have &#8230; <a href="http://pj.lightfoot.cc/2011/10/async-calls-in-silverlight-and-wpf-clients/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Info</h2>
<h3>Breakout Session :: 400 (Expert) :: Developer Tools, Languages and Frameworks</h3>
<p><em>&#8220;Whenever doing blocking tasks, particularly service calls in a Silverlight or Windows Presentation Foundation (WPF) client, you will need to make those calls asynchronously. While async calls have been around for a long time in Microsoft .NET, the patterns for addressing them have been changing and improving. This session covers several common patterns for addressing async calls in client applications, including new and emerging approaches to async patterns such as Reactive Extensions that let you treat asynchronous execution like a LINQ collection and the Task-based Async pattern and keywords coming for the C# and VB languages. This session takes the mystery and confusion out of what happens and when &#8212; and how to keep your code clean and safe in an inherently asynchronous client world.&#8221;</em></p>
<p><a href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV340" title="Video" target="_blank">Video</a></p>
<h2>Highlights</h2>
<p>This session provided a practical overview of asynchrony from the perspective of the UI (and by extension the affinity that UI objects and <code>ObservableCollection&lt;T></code> has with the UI thread). Some rule-of-thumb tips are:</p>
<ul>
<li>Never block the UI thread. If it takes longer than 50-60ms, async it.</li>
<li>Never access UI objects from a non-UI thread.</li>
<li>Don&#8217;t access variables from multiple threads with protection.</li>
</ul>
<p>The asynchronous patterns provided by the .Net Framework are:</p>
<ul>
<li>Begin/End Async Pattern</li>
<li>Async/Completed Pattern</li>
<li>Task Parallel Library (<code>Task&lt;T></code>)</li>
<li>Task-based Async (<code>async</code> and <code>await</code> keywords)</li>
<li>Reactive Extensions (LINQ + Observables + Schedulers)</li>
</ul>
<h2>Links</h2>
<ul>
<li><a href="http://oreilly.com/catalog/9780596102074" title="Book: Programming .NET Components, Second Edition" target="_blank">Book: Programming .NET Components, Second Edition</a></li>
<li><a href="http://msdn.microsoft.com/en-us/devlabs/gg577609" title="The Reactive Extensions (Rx)" target="_blank">The Reactive Extensions (Rx)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/vstudio/gg316360" title="Visual Studio Asynchronous Programming" target="_blank">Visual Studio Asynchronous Programming</a></li>
<li><a href="http://blog.markpearl.co.za" title="Mark Pearl" target="_blank">Mark Pearl</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/10/async-calls-in-silverlight-and-wpf-clients/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Demystifying .Net Asynchronous Programming</title>
		<link>http://pj.lightfoot.cc/2011/10/demystifying-net-asynchronous-programming/</link>
		<comments>http://pj.lightfoot.cc/2011/10/demystifying-net-asynchronous-programming/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 19:01:13 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[Asynchrony]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Tech·Ed]]></category>
		<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=323</guid>
		<description><![CDATA[Info Breakout Session :: 400 (Expert) :: Developer Tools, Languages and Frameworks &#8220;Asynchronous programming is no longer an option; it’s become a must on various platforms, including Silverlight, Windows Phone 7, and various data-centric frameworks. Unfortunately, dealing with asynchrony is &#8230; <a href="http://pj.lightfoot.cc/2011/10/demystifying-net-asynchronous-programming/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Info</h2>
<h3>Breakout Session :: 400 (Expert) :: Developer Tools, Languages and Frameworks</h3>
<p><em>&#8220;Asynchronous programming is no longer an option; it’s become a must on various platforms, including Silverlight, Windows Phone 7, and various data-centric frameworks. Unfortunately, dealing with asynchrony is way too hard in today&#8217;s world of development tools and frameworks. The huge amount of manual and error-prone plumbing leads to incomprehensible and hard to maintain code. As we reach out to services in the cloud, the desire for asynchronous computation is ever increasing, requiring a fresh look on the problems imposed by reactive programming. In this session, we explore various methodologies to address asynchronous programming, and explain how they relate and differ. First, we’ll explore existing patterns and libraries – such as the TPL – to sketch some of the pain-points. Armed with this knowledge, we’ll approach the problem from different angles, including a language-centric view with F#’s asynchronous workflows and the upcoming asynch and await features in C# and Visual Basic. Next, we’ll move beyond sequential composition of asynchronous computations, and introduce the Reactive Extensions (Rx) that enable you to express rich queries – even using LINQ syntax – over asynchronous push-based “reactive” event streams.&#8221;</em></p>
<h2>Highlights</h2>
<p>The discussion starts by introducing the concepts of Asynchrony (multiple parties evolving in time independently), Concurrency (order in which multiple tasks execute is not determined) and Parralelism (multiple tasks working together), and some wording (&#8220;Reactive&#8221;, &#8220;Callbacks&#8221;, &#8220;Events&#8221;) that typically describe asynchronous situations.</p>
<p>Abstractions in .Net that support asynchrony are: Asynchronous Programming Model (uses callback functions), Event-Based Asynchronous Pattern (uses completion events), and the BackgroundWorker Component.</p>
<p>New tools and abstractions being introduced in upcoming versions of C# and .Net include:</p>
<ul>
<li><code>await</code> keyword suspends the code that follows the keyword into a continuation for the asynchronous operation completion. The keyword (and the code following it) can be safely wrapped in standard control statements such as <code>while{}</code>, or <code>try{} catch{}</code> blocks.</li>
<li><code>Task&lt;T></code> is a representation of computations (<code>.StartNew()</code>), and hooks (<code>.ContinueWith()</code>) for continuations (which allows for sequencing). <code>Task.Result</code> blocks the calling thread.</li>
<li><code>BeginVerb</code>-<code>EndVerb</code> patterned functions and <code>VerbAsync</code> functions are complemented with <code>VerbTaskAsync</code> functions that return <code>Task&lt;T></code>.</li>
</ul>
<h2>Some code examples:</h2>
<h3>Example 1</h3>
<div class="code">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="csharp" style="font-family:Monaco, Consolas, Andale Mono, DejaVu Sans Mono, monospace;">var report <span style="color: #008000;">=</span> Task<span style="color: #008000;">.</span><span style="color: #0000FF;">Factory</span><span style="color: #008000;">.</span><span style="color: #0000FF;">StartNew</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> GetFileData<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
			 <span style="color: #008000;">.</span><span style="color: #0000FF;">ContinueWith</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> Analyze<span style="color: #008000;">&#40;</span>x<span style="color: #008000;">.</span><span style="color: #0000FF;">Result</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
			 <span style="color: #008000;">.</span><span style="color: #0000FF;">ContinueWith</span><span style="color: #008000;">&#40;</span>y <span style="color: #008000;">=&gt;</span> Summarize<span style="color: #008000;">&#40;</span>y<span style="color: #008000;">.</span><span style="color: #0000FF;">Result</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

</div>
<h3>Example 2</h3>
<div class="code">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="csharp" style="font-family:Monaco, Consolas, Andale Mono, DejaVu Sans Mono, monospace;">async <span style="color: #6666cc; font-weight: bold;">void</span> DoWorkAsync<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	var t1 <span style="color: #008000;">=</span> ProcessFeedAsync<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;x&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	var t2 <span style="color: #008000;">=</span> ProcessFeedAsync<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;y&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	await Task<span style="color: #008000;">.</span><span style="color: #0000FF;">WhenAll</span><span style="color: #008000;">&#40;</span>t1, t2<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	DisplayMessage<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Done&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
async Task ProcessFeedAsync<span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">string</span> url <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	var text <span style="color: #008000;">=</span> await DownloadFeedAsync<span style="color: #008000;">&#40;</span>url<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	var doc <span style="color: #008000;">=</span> ParseFeedIntoDoc<span style="color: #008000;">&#40;</span>text<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	await SaveDocAsync<span style="color: #008000;">&#40;</span>doc<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	ProcessLog<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteEntry</span><span style="color: #008000;">&#40;</span>url<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

</div>
<h2>Reactive Extension (Rx)</h2>
<p>Rx is a library for composing asynchronous and event-based programs using observable sequences. Think <code>IObservable&lt;T></code> and <code>IObserver&lt;T></code> (subscribe, push) vs. <code>IEnumerable&lt;T></code> and <code>IEnumerator&lt;T></code> (pull, blocking).</p>
<p>The concepts introduced by Rx are best studied through additional research into some of the functions it provides:</p>
<ul>
<li><code>.Throttle()</code></li>
<li><code>.DistinctUntilChanged()</code></li>
<li><code>.TakeUntil()</code></li>
<li><code>.ObserveOn()</code></li>
<li><code>.Subscribe()</code></li>
</ul>
<p>The relationship between the various paradigms is best visualized on a graph representing (Axis Y): Single Value vs. Multiple Values over (Axis X): Syncrhonous vs. Asynchronous &#8230; the four distinct quadrants of this graph are:</p>
<ul>
<li>Single-Value Synchronous: <code>Func&lt;T></code></li>
<li>Single-Value Asynchronous: <code>Task&lt;T></code> (and <code>await</code>)</li>
<li>Multiple-Value Synchronous: <code>IEnumerable&lt;T></code></li>
<li>Multiple-Value Asynchronous: <code>IObservable&lt;T></code> (and <code>.Subscribe()</code>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/10/demystifying-net-asynchronous-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MVC, MVP &amp; MVVM: Comparison of Architectural Patterns</title>
		<link>http://pj.lightfoot.cc/2011/10/mvc-mvp-mvvm-comparison-of-architectural-patterns/</link>
		<comments>http://pj.lightfoot.cc/2011/10/mvc-mvp-mvvm-comparison-of-architectural-patterns/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 18:48:48 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Tech·Ed]]></category>
		<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=314</guid>
		<description><![CDATA[Info Lunchbox Session :: 300 (Advanced) :: Developer Practices &#8220;This session compares the architectural patterns of Model-View-Controller (MVC), Model-View-Presenter (MVP) and Model-View-View Model (MVVM). Each pattern creates testable, maintainable and reusable application components, however, there are differences that suit each &#8230; <a href="http://pj.lightfoot.cc/2011/10/mvc-mvp-mvvm-comparison-of-architectural-patterns/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Info</h2>
<h3>Lunchbox Session :: 300 (Advanced) :: Developer Practices</h3>
<p><em>&#8220;This session compares the architectural patterns of Model-View-Controller (MVC), Model-View-Presenter (MVP) and Model-View-View Model (MVVM). Each pattern creates testable, maintainable and reusable application components, however, there are differences that suit each approach to specific types of developer tooling. The presentation first looks at the basic theory and differences between the approaches; then uses demos that show how each apply to Microsoft ASP.NET, Microsoft Silverlight/Windows Presentation Foundation (WPF) and Microsoft SharePoint developer application projects.&#8221;</em></p>
<p><a href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR305" title="Video" target="_blank">Video</a></p>
<h2>Highlights</h2>
<p>The MVC pattern is distinct in that the user interacts directly with the Controller objects, while both others represent patters where the user interacts with the View objects. MVC is primarily suited for use in the ASP.Net MVC Framework, as the underlying concepts are fundamentaly built in to the framework itself. With some effort however, MVC can be implemented directly onto standard ASP.Net (which is of course what the MVC Framework essentially does for you). WinForms applications could also fit into the MVC paradigm, and can be built on this pattern with even less effort than standard ASP.Net. In this pattern: M = Model, V = View and C = Controller; where M is unaware of V and C, V is aware of M, and C is aware of both V and M.</p>
<p>MVP lends itself well to &#8220;standard&#8221; ASP.Net projects and SharePoint development, with the assumption (and indeed &#8220;requirement&#8221;) that while Views are the point of entry and interaction with the user, they &#8220;dumb [themselves] down&#8221; and relinquish control to the Presenters that they instantiate. In this pattern: M = Model, V = View and P = Presenter; where M is unaware of V and P, V is aware of P, and P is aware of both M and an interface representative of V.</p>
<p>MVVM is the most recent evolution of these &#8220;separation of concern&#8221; patterns, and is most useful in the XAML (Silverlight and WPF) environment, which has strong data- and command-binding support. Similar to MVP, Views in MVVM also defer all business logic to the ViewModel. Communication between View and ViewModel is facilitated through a combination of Command Bindings and Events (behaviour-driven communication) and Data Binding (data-driven communication). In this pattern: M = Model, V = View and VM = ViewModel; where M is unaware of V and VM, V is aware of VM, and VM is aware of M.</p>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/10/mvc-mvp-mvvm-comparison-of-architectural-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Coded UI Tests with VS 2010</title>
		<link>http://pj.lightfoot.cc/2011/10/building-coded-ui-tests-with-vs-2010/</link>
		<comments>http://pj.lightfoot.cc/2011/10/building-coded-ui-tests-with-vs-2010/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 18:47:37 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[Tech·Ed]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Coded UI Tests]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=312</guid>
		<description><![CDATA[Info Breakout Session :: 300 (Advanced) :: Developer Tools, Languages and Frameworks &#8220;Coded UI tests allow developers to create fully-automated, functional UI tests which can be used to quickly alert a team about regressions. These are easy to create, but &#8230; <a href="http://pj.lightfoot.cc/2011/10/building-coded-ui-tests-with-vs-2010/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Info</h2>
<h3>Breakout Session :: 300 (Advanced) :: Developer Tools, Languages and Frameworks</h3>
<p><em>&#8220;Coded UI tests allow developers to create fully-automated, functional UI tests which can be used to quickly alert a team about regressions. These are easy to create, but can become tricky to build in a robust manner which can sustain changes to your application over time. In this demo-rich session we will examine patterns and practices you can employ for building great coded UI tests.&#8221;</em></p>
<h2>Highlights</h2>
<ul>
<li>
Using a combination of Visual Studio (Premium or Ultimate), Feature Pack 2 (from MSDN subscription), C# or VB, and (optionally) Microsoft Test Manager, coded UI tests can be used to run functional regression tests manually (from VS or TM) or as part of an automated build process.
</li>
<li>
Tests are created by recording actions from within Visual Studio, or using an existing action recording from Test Manager.
</li>
<li>
The <strong>UI Map Designer</strong> serves as a mapping between the test code and application UI, and allows editing of test methods, control search- and filter properties, etc.
</li>
<li>
Extended functionality includes the ability to add validation with test builder by inspecting control properties, data-binding tests to a database, CSV file or XML file (where test will run for every row in the data), etc.
</li>
<li>
<em>Tip:</em> To record validation inspections, a test can be automated into a specific state by running the previously recorded test up until the point of validation.
</li>
<li>
The <code>TestContext</code> object is used to access test data, add result files, etc.
</li>
<li>
Test results can be published to TFS and attached to a new work item.
</li>
</ul>
<h2>Links</h2>
<ul>
<li><a href="http://blogs.msdn.com/briankel" title="Brian Keller" target="_blank">Brian Keller</a></li>
<li><a href="http://testapi.codeplex.com" title="TestApi - a library of Test APIs" target="_blank">TestApi &#8211; a library of Test APIs</a></li>
<li><a href="http://tinyurl.com/multipleuimaps" title="Walkthrough: Using multiple Coded UI maps in test automation" target="_blank">Walkthrough: Using multiple Coded UI maps in test automation</a></li>
<li><a href="http://cuite.codeplex.com" title="CUITe (Coded UI Test enhanced) Framework" target="_blank">CUITe (Coded UI Test enhanced) Framework</a></li>
<li><a href="http://tinyurl.com/playbacksettings" title="Configuring Playback in Visual Studio 2010" target="_blank">Configuring Playback in Visual Studio 2010</a></li>
<li><a href="http://support.microsoft.com/kb/971513" title="Description of the Windows Automation API" target="_blank">Description of the Windows Automation API</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ff468125.aspx" title="Using Coded UI Tests in Load Tests" target="_blank">Using Coded UI Tests in Load Tests</a></li>
</ul>
<h2>Further Reading</h2>
<ul>
<li>Lab Management</li>
<li>Hyper-V</li>
<li>&#8220;How we test software at Microsoft&#8221;</li>
<li><a href="http://tinyurl.com/alm2010book" title="Book: Professional Application Lifecycle Management with Visual Studio 2010" target="_blank">Book: Professional Application Lifecycle Management with Visual Studio 2010</a></li>
<li><a href="http://tinyurl.com/tfsbook" title="Book: Professional Team Foundation Server 2010" target="_blank">Book: Professional Team Foundation Server 2010</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/10/building-coded-ui-tests-with-vs-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Agile Anti-Patterns!</title>
		<link>http://pj.lightfoot.cc/2011/10/agile-anti-patterns/</link>
		<comments>http://pj.lightfoot.cc/2011/10/agile-anti-patterns/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 20:36:24 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Tech·Ed]]></category>
		<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=308</guid>
		<description><![CDATA[Info Breakout Session :: 200 (Intermediate) :: Developer Practices &#8220;The popularity of agile software development processes and methodologies is imminent and fast growing. Many organizations and projects turn towards agile to help solve the problems of traditional software development. Scrum, &#8230; <a href="http://pj.lightfoot.cc/2011/10/agile-anti-patterns/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Info</h2>
<h3>Breakout Session :: 200 (Intermediate) :: Developer Practices</h3>
<p><em>&#8220;The popularity of agile software development processes and methodologies is imminent and fast growing. Many organizations and projects turn towards agile to help solve the problems of traditional software development. Scrum, extreme programming, test driven development, and lean are no longer the new kids on the block. However, with the rising popularity of agile, mainly due to lack of experience or management over-expecting results, in coming years many agile projects will fail miserably. Agile is not the silver bullet.&#8221;</em></p>
<p><a href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR206" title="Video" target="_blank">Video</a></p>
<h2>Highlights</h2>
<p><strong>List of Anti-Patterns:</strong></p>
<ol>
<li>Traditional approaches are evil</li>
<li>Velocity is unimportant</li>
<li>Senior guy estimates the work</li>
<li>Open plan office and cubicles</li>
<li>Missing product owner</li>
<li>Mini waterfall</li>
<li>Change iteration length</li>
<li>Changing requirements intra-sprint</li>
<li>Task boards are old school</li>
<li>Documenting everything perfectly</li>
<li>Pick the low hanging fruit</li>
<ul>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/10/agile-anti-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What Code-DB gap? Introducing Project Juneau</title>
		<link>http://pj.lightfoot.cc/2011/10/what-code-db-gap-introducing-project-juneau/</link>
		<comments>http://pj.lightfoot.cc/2011/10/what-code-db-gap-introducing-project-juneau/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 20:32:01 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[ALM]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Tech·Ed]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=306</guid>
		<description><![CDATA[Info Breakout Session :: 300 (Advanced) :: Developer Tools, Languages and Frameworks &#8220;Project Juneau is a new toolset being release with Project Denali which provides a rich database design and editing environment directly within Visual Studio. Some of the features &#8230; <a href="http://pj.lightfoot.cc/2011/10/what-code-db-gap-introducing-project-juneau/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Info</h2>
<h3>Breakout Session :: 300 (Advanced) :: Developer Tools, Languages and Frameworks</h3>
<p><em>&#8220;Project Juneau is a new toolset being release with Project Denali which provides a rich database design and editing environment directly within Visual Studio. Some of the features include rich versioning of databases, dependency checks, rich intelligence, debugging support and database refactoring tools. Join William as he guides you through a few of his favourite offerings coming from Juneau.&#8221;</em></p>
<h2>Highlights</h2>
<p>Project Juneau addresses these major pain points (among many others):</p>
<ul>
<li>Database versioning</li>
<li>Database dependency management</li>
<li>Production drift</li>
</ul>
<p>This is one talk I&#8217;m not even going to attempt to summarize, as even the talk itself was a summary of but a small subset of features introduced by Juneau. I&#8217;ll simply list those here, along with the clearly stated goal of Project Juneau, which is to enhance the continuous, integrated development experience between database and code (which is to say that these and many other &#8220;SQL-like&#8221; features are being brought forward into Visual Studio by this toolset:</p>
<ul>
<li>SQL Explorer</li>
<li>Intellisense</li>
<li>Column Tooltips</li>
<li>Table Designer / Script / Model Diagram (all synchronized based on customizable user settings)</li>
<li>Preview Database Changes (warnings, highlights, user actions)</li>
<li>SQL/CLR</li>
<li>T-SQL Debugging with Step Through, Watch Variables, etc.</li>
<li>Local Database Runtime with VS Integration, Schema-based Files</li>
<li>Schema Compare with Visual Diff</li>
<li>Refactoring (Expand Wildcards, Rename, etc.) and other &#8220;Managed Code&#8221;-like features (&#8220;Go to Definition&#8221;, etc.)</li>
<li>Compile-time Validation of Schemas</li>
<li>Database Publishing (target platform aware, with Direct / Script / DAC modes)</li>
</ul>
<p>Data can be managed through Pre- and/or Post-Deployment Scripts.</p>
<p><a href="http://www.williamb.net/Blog/Posts/TechEd2011SlideDecks" title="TechEd 2011 Slide Decks" target="_blank">TechEd 2011 Slide Decks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/10/what-code-db-gap-introducing-project-juneau/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript, jQuery and Ajax Patterns</title>
		<link>http://pj.lightfoot.cc/2011/10/javascript-jquery-and-ajax-patterns/</link>
		<comments>http://pj.lightfoot.cc/2011/10/javascript-jquery-and-ajax-patterns/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 20:14:29 +0000</pubDate>
		<dc:creator>Peter-John</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Tech·Ed]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Patterns]]></category>

		<guid isPermaLink="false">http://pj.lightfoot.cc/?p=302</guid>
		<description><![CDATA[Info Whiteboard :: 300 (Advanced) :: Developer Tools, Languages and Frameworks &#8220;Do you get lost in your client side code? Do you find debugging client side JavaScript painful? Is working with JavaScript &#8216;fiddly and annoying&#8217;? If you answer &#8216;yes&#8217; to &#8230; <a href="http://pj.lightfoot.cc/2011/10/javascript-jquery-and-ajax-patterns/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Info</h2>
<h3>Whiteboard :: 300 (Advanced) :: Developer Tools, Languages and Frameworks</h3>
<p><em>&#8220;Do you get lost in your client side code? Do you find debugging client side JavaScript painful? Is working with JavaScript &#8216;fiddly and annoying&#8217;? If you answer &#8216;yes&#8217; to any of these questions then this is stuff you want to hear. In this talk we take on a hands on approach to some of the more useful tips &#8216;n tricks and patterns when working with JavaScript. The examples have been drawn from real issues hit during development so they are practical solutions to real problems we&#8217;ve hit. Find out more about ways to make working with JavaScript easier in the team, useful patterns in talking to the server, debugging tips and tricks, code layout, fetching data from the server, posting data to the server.&#8221;</em></p>
<h2>Highlights</h2>
<p>Some best practices outlined in this session include (see the accompanying code snippets):</p>
<ul>
<li>JavaScript Encapsulation</li>
<li>One-to-one mapping between UI and .js (e.g. Index.aspx and Index.js with <code>function Index() { ... }<br />
</code></li>
<li>JS Outlining (see link)</li>
<li>Use a JS and CSS minifier</li>
<li>Don&#8217;t overuse JSON post back patterns</li>
</ul>
<h3>UI Code</h3>
<div class="code">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="html" style="font-family:Monaco, Consolas, Andale Mono, DejaVu Sans Mono, monospace;">&lt;script&gt;
   var x = new Index();
   x.PathToUrl = &quot;http://mysite&quot;;
   x.Load();
&lt;/script&gt;
&nbsp;
&lt;!-- snip --&gt;
&nbsp;
&lt;button id=&quot;SaveButton&quot;/&gt;</pre></td></tr></table></div>

</div>
<h3>JS Code</h3>
<div class="code">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:Monaco, Consolas, Andale Mono, DejaVu Sans Mono, monospace;"><span style="color: #003366; font-weight: bold;">function</span> Index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   PathToUrl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
   Form <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">Load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#SaveButton&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">Save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">Save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> ... <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<h2>Links</h2>
<ul>
<li><a href="http://jsoutlining.codeplex.com/" title="Visual Studio 2010 JavaScript and CSS Outlining" target="_blank">Visual Studio 2010 JavaScript and CSS Outlining</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://pj.lightfoot.cc/2011/10/javascript-jquery-and-ajax-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

