<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Where did the time go? - C#</title>
    <link>http://blog.j-maxx.net/</link>
    <description>Brain Powered</description>
    <language>en-us</language>
    <copyright>Jeff Klawiter</copyright>
    <lastBuildDate>Mon, 14 Sep 2009 22:18:17 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>Jeff.Klawiter@sierra-bravo.com</managingEditor>
    <webMaster>Jeff.Klawiter@sierra-bravo.com</webMaster>
    <item>
      <trackback:ping>http://blog.j-maxx.net/Trackback.aspx?guid=948219d5-1884-4bb2-ad08-4cefbf0c5c5e</trackback:ping>
      <pingback:server>http://blog.j-maxx.net/pingback.aspx</pingback:server>
      <pingback:target>http://blog.j-maxx.net/PermaLink,guid,948219d5-1884-4bb2-ad08-4cefbf0c5c5e.aspx</pingback:target>
      <dc:creator>Jeff Klawiter</dc:creator>
      <wfw:comment>http://blog.j-maxx.net/CommentView,guid,948219d5-1884-4bb2-ad08-4cefbf0c5c5e.aspx</wfw:comment>
      <wfw:commentRss>http://blog.j-maxx.net/SyndicationService.asmx/GetEntryCommentsRss?guid=948219d5-1884-4bb2-ad08-4cefbf0c5c5e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
With the advent of ASP.NET MVC 2.0 and the new templated helpers we’re once again
having to write out our entire data objects. This is something that ORM tools like
LINQ to SQL and LINQ to Entities were supposed to alleviate. Even better is we must
now implement a class in 3 files.
</p>
        <p>
Case in point: <a title="http://blog.pagedesigners.co.nz/archive/2009/08/06/asp.net-mvc-2-ndash-buddy-classes-for-your-models.aspx" href="http://blog.pagedesigners.co.nz/archive/2009/08/06/asp.net-mvc-2-ndash-buddy-classes-for-your-models.aspx">http://blog.pagedesigners.co.nz/archive/2009/08/06/asp.net-mvc-2-ndash-buddy-classes-for-your-models.aspx</a></p>
        <p>
The idea of “Partial Properties” follows the convention for Partial Classes and not
Partial Methods. With Partial classes you can have the same class defined in two files.
This is extremely helpful with extending generated code. With Partial Methods, one
partial class file defines a method and another partial class file may if it choose
implement that method. If the method is never implemented then the compiler completely
throws away any code that may have referenced that method. 
</p>
        <p>
During a PDC talk Anders said that he couldn’t see a reason why we should implement
Partial Properties but it’s becoming clear to me that we are starting to have the
need. 
</p>
        <p>
Here’s the current situation:
</p>
        <ol>
          <li>
You create your models with LINQ to SQL or LINQ to Entities. 
</li>
          <li>
You have no control over the auto-generated code so you implement partial classes
for each class made in a separate file 
</li>
          <li>
You need to annotate the properties in the generated classes so you then have to create
a buddy class 
</li>
          <li>
You take all the properties of the generated class and type them in and add attributes
to them and thus mostly defeating the purpose of #1 
</li>
        </ol>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:8f971c51-66e4-493d-9173-de64c9ef9dd2" class="wlWriterEditableSmartContent">
          <pre name="code" class="c#">//GeneratedClass.Designer.cs (the generated file)
public partial class GeneratedClass
{
	private string _name;
	public string Name
	{
		get{return _name;}
		set{_name = value;}
	}
}

//GeneratedClass.cs (your file)
[MetadataType(typeof(GeneratedClass_Metadata))]
public partial class GeneratedClass
{
	
}

//GeneratedClass.cs or GeneratedClass.Meta.cs (your other file)
public partial class GeneratedClass_Metadata
{
	[Required(ErrorMessage="Name Required")]
	public string Name{get;set;}
}</pre>
        </div>
        <p>
In the end you end up with 2-3 files and 3 implementations of your class. You also
end up with the compiler generating more classes that their only use are for attributes. 
</p>
        <p>
With a “Partial Property” generated code could expose all of the public properties
like so
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:f1d9d2d5-92bf-4e76-8245-30bac85bf0a7" class="wlWriterEditableSmartContent">
          <pre name="code" class="c#">//GeneratedClass.Designer.cs (the generated file)
public partial class GeneratedClass
{
	private string _name;
	public partial string Name
	{
		get{return _name;}
		set{_name = value;}
	}
}
//GeneratedClass.cs (your file)
public partial class GeneratedClass
{
	[Required(ErrorMessage="Name Required")]
	public partial string Name;
}</pre>
        </div>
        <p>
This may all be moot if we can at least get some tooling support for MetaDataType.
We could use a Refactor –&gt; Generate Buddy Class. This could auto-gen the metadata
class for you so all you have to do is write the attributes in. Maybe even Class Diagram
support?
</p>
        <img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=948219d5-1884-4bb2-ad08-4cefbf0c5c5e" />
      </body>
      <title>The Case for Partial Properties</title>
      <guid isPermaLink="false">http://blog.j-maxx.net/PermaLink,guid,948219d5-1884-4bb2-ad08-4cefbf0c5c5e.aspx</guid>
      <link>http://blog.j-maxx.net/2009/09/14/TheCaseForPartialProperties.aspx</link>
      <pubDate>Mon, 14 Sep 2009 22:18:17 GMT</pubDate>
      <description>&lt;p&gt;
With the advent of ASP.NET MVC 2.0 and the new templated helpers we’re once again
having to write out our entire data objects. This is something that ORM tools like
LINQ to SQL and LINQ to Entities were supposed to alleviate. Even better is we must
now implement a class in 3 files.
&lt;/p&gt;
&lt;p&gt;
Case in point: &lt;a title="http://blog.pagedesigners.co.nz/archive/2009/08/06/asp.net-mvc-2-ndash-buddy-classes-for-your-models.aspx" href="http://blog.pagedesigners.co.nz/archive/2009/08/06/asp.net-mvc-2-ndash-buddy-classes-for-your-models.aspx"&gt;http://blog.pagedesigners.co.nz/archive/2009/08/06/asp.net-mvc-2-ndash-buddy-classes-for-your-models.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The idea of “Partial Properties” follows the convention for Partial Classes and not
Partial Methods. With Partial classes you can have the same class defined in two files.
This is extremely helpful with extending generated code. With Partial Methods, one
partial class file defines a method and another partial class file may if it choose
implement that method. If the method is never implemented then the compiler completely
throws away any code that may have referenced that method. 
&lt;/p&gt;
&lt;p&gt;
During a PDC talk Anders said that he couldn’t see a reason why we should implement
Partial Properties but it’s becoming clear to me that we are starting to have the
need. 
&lt;/p&gt;
&lt;p&gt;
Here’s the current situation:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
You create your models with LINQ to SQL or LINQ to Entities. 
&lt;/li&gt;
&lt;li&gt;
You have no control over the auto-generated code so you implement partial classes
for each class made in a separate file 
&lt;/li&gt;
&lt;li&gt;
You need to annotate the properties in the generated classes so you then have to create
a buddy class 
&lt;/li&gt;
&lt;li&gt;
You take all the properties of the generated class and type them in and add attributes
to them and thus mostly defeating the purpose of #1 
&lt;/li&gt;
&lt;/ol&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:8f971c51-66e4-493d-9173-de64c9ef9dd2" class="wlWriterEditableSmartContent"&gt;&lt;pre name="code" class="c#"&gt;//GeneratedClass.Designer.cs (the generated file)
public partial class GeneratedClass
{
	private string _name;
	public string Name
	{
		get{return _name;}
		set{_name = value;}
	}
}

//GeneratedClass.cs (your file)
[MetadataType(typeof(GeneratedClass_Metadata))]
public partial class GeneratedClass
{
	
}

//GeneratedClass.cs or GeneratedClass.Meta.cs (your other file)
public partial class GeneratedClass_Metadata
{
	[Required(ErrorMessage="Name Required")]
	public string Name{get;set;}
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
In the end you end up with 2-3 files and 3 implementations of your class. You also
end up with the compiler generating more classes that their only use are for attributes. 
&lt;/p&gt;
&lt;p&gt;
With a “Partial Property” generated code could expose all of the public properties
like so
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:f1d9d2d5-92bf-4e76-8245-30bac85bf0a7" class="wlWriterEditableSmartContent"&gt;&lt;pre name="code" class="c#"&gt;//GeneratedClass.Designer.cs (the generated file)
public partial class GeneratedClass
{
	private string _name;
	public partial string Name
	{
		get{return _name;}
		set{_name = value;}
	}
}
//GeneratedClass.cs (your file)
public partial class GeneratedClass
{
	[Required(ErrorMessage="Name Required")]
	public partial string Name;
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
This may all be moot if we can at least get some tooling support for MetaDataType.
We could use a Refactor –&amp;gt; Generate Buddy Class. This could auto-gen the metadata
class for you so all you have to do is write the attributes in. Maybe even Class Diagram
support?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=948219d5-1884-4bb2-ad08-4cefbf0c5c5e" /&gt;</description>
      <comments>http://blog.j-maxx.net/CommentView,guid,948219d5-1884-4bb2-ad08-4cefbf0c5c5e.aspx</comments>
      <category>C#</category>
      <category>Rant</category>
    </item>
    <item>
      <trackback:ping>http://blog.j-maxx.net/Trackback.aspx?guid=4615cd55-a3f0-4d8e-9131-f82995cf1470</trackback:ping>
      <pingback:server>http://blog.j-maxx.net/pingback.aspx</pingback:server>
      <pingback:target>http://blog.j-maxx.net/PermaLink,guid,4615cd55-a3f0-4d8e-9131-f82995cf1470.aspx</pingback:target>
      <dc:creator>Jeff Klawiter</dc:creator>
      <wfw:comment>http://blog.j-maxx.net/CommentView,guid,4615cd55-a3f0-4d8e-9131-f82995cf1470.aspx</wfw:comment>
      <wfw:commentRss>http://blog.j-maxx.net/SyndicationService.asmx/GetEntryCommentsRss?guid=4615cd55-a3f0-4d8e-9131-f82995cf1470</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">While browsing through MSDN blogs I came
across this nice little post. <a href="http://blogs.msdn.com/dparys/archive/2008/10/28/neue-m-glichkeiten-in-c-4-0.aspx">http://blogs.msdn.com/dparys/archive/2008/10/28/neue-m-glichkeiten-in-c-4-0.aspx</a> .
After translating the page I found that he linked to the new C# 40 page <a href="http://code.msdn.microsoft.com/csharpfuture">http://code.msdn.microsoft.com/csharpfuture</a><br /><br />
I played around with VS 2010 last night. I was able to test the dynamic keyword. It
works as advertised but the biggest thing one has to realize is using it removes intellisense
for that variable. Compiling type safety as well. I hope they'll be able to add some
sort of limited intellisense by looking at the last assigned type.<br /><br />
Also on the Dynamic front is DynamicObject. A new base object type that allows for
on the fly Property declaration. The DynamicObject uses a PropertyBag (looks like
a Dictionary&lt;string,object&gt;). You can declare properties on the fly. Like<br /><pre name="code" class="c#">public class MyBag : DynamicObject
{
// überschreibt Getter / Setter
} 
dynamic b = new MyBag();
b.Id = 124;
b.Name = "Windows 7"
b.Price = 499.99m;
b.IsAvailable = false;

</pre>One
thing I was unable to figure out was the optional, default and named parameters. Again
the blog provided some answers.<br /><br /><pre name="code" class="c#">public void InsertCustomer( int customerId,
                          string companyName = "Neue Firma",
                          decimal creditLimit = 2000m )
{
}

InsertCustomer( 1, creditLimit: 2000m );  

InsertCustomer( creditLimit: 2000m, customerId: 1 );

</pre><br /><br /><br /><br /><p></p><img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=4615cd55-a3f0-4d8e-9131-f82995cf1470" /></body>
      <title>Update on new C# 4 features</title>
      <guid isPermaLink="false">http://blog.j-maxx.net/PermaLink,guid,4615cd55-a3f0-4d8e-9131-f82995cf1470.aspx</guid>
      <link>http://blog.j-maxx.net/2008/10/28/UpdateOnNewC4Features.aspx</link>
      <pubDate>Tue, 28 Oct 2008 14:13:13 GMT</pubDate>
      <description>While browsing through MSDN blogs I came across this nice little post. &lt;a href="http://blogs.msdn.com/dparys/archive/2008/10/28/neue-m-glichkeiten-in-c-4-0.aspx"&gt;http://blogs.msdn.com/dparys/archive/2008/10/28/neue-m-glichkeiten-in-c-4-0.aspx&lt;/a&gt; .
After translating the page I found that he linked to the new C# 40 page &lt;a href="http://code.msdn.microsoft.com/csharpfuture"&gt;http://code.msdn.microsoft.com/csharpfuture&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
I played around with VS 2010 last night. I was able to test the dynamic keyword. It
works as advertised but the biggest thing one has to realize is using it removes intellisense
for that variable. Compiling type safety as well. I hope they'll be able to add some
sort of limited intellisense by looking at the last assigned type.&lt;br&gt;
&lt;br&gt;
Also on the Dynamic front is DynamicObject. A new base object type that allows for
on the fly Property declaration. The DynamicObject uses a PropertyBag (looks like
a Dictionary&amp;lt;string,object&amp;gt;). You can declare properties on the fly. Like&lt;br&gt;
&lt;pre name="code" class="c#"&gt;public class MyBag : DynamicObject
{
// überschreibt Getter / Setter
} 
dynamic b = new MyBag();
b.Id = 124;
b.Name = "Windows 7"
b.Price = 499.99m;
b.IsAvailable = false;

&lt;/pre&gt;One
thing I was unable to figure out was the optional, default and named parameters. Again
the blog provided some answers.&lt;br&gt;
&lt;br&gt;
&lt;pre name="code" class="c#"&gt;public void InsertCustomer( int customerId,
                          string companyName = "Neue Firma",
                          decimal creditLimit = 2000m )
{
}

InsertCustomer( 1, creditLimit: 2000m );  

InsertCustomer( creditLimit: 2000m, customerId: 1 );

&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=4615cd55-a3f0-4d8e-9131-f82995cf1470" /&gt;</description>
      <comments>http://blog.j-maxx.net/CommentView,guid,4615cd55-a3f0-4d8e-9131-f82995cf1470.aspx</comments>
      <category>C#</category>
      <category>C# 4.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.j-maxx.net/Trackback.aspx?guid=6af08b32-a592-4086-b634-04bce5effdb3</trackback:ping>
      <pingback:server>http://blog.j-maxx.net/pingback.aspx</pingback:server>
      <pingback:target>http://blog.j-maxx.net/PermaLink,guid,6af08b32-a592-4086-b634-04bce5effdb3.aspx</pingback:target>
      <dc:creator>Jeff Klawiter</dc:creator>
      <wfw:comment>http://blog.j-maxx.net/CommentView,guid,6af08b32-a592-4086-b634-04bce5effdb3.aspx</wfw:comment>
      <wfw:commentRss>http://blog.j-maxx.net/SyndicationService.asmx/GetEntryCommentsRss?guid=6af08b32-a592-4086-b634-04bce5effdb3</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">Well I spent most of the day working on
some peculiar problems with PICK. Then left to take my girlfriend out for her birthday.
Just now catching up on whats gone on today at PDC. Man it seems like it was a huge
day.<br /><br />
First off Windows Azure and the new .NET Services. From what I've read so far I can
see some compelling uses for the .NET services and sharing content, id's and roles
around the web. 
<br /><br />
The big one that I haven't seen much press on yet is C# 4.0. Looks like we are getting
dynamic binding in the language. While this loses compile type safety it gives C#
good ground against things like Ruby and PHP.<br /><br />
Named, Optional and Default parameters. Oh how I've been waiting for these since switching
to .NET from PHP. I used to take advantage of these features all the time. It annoys
me when I can use them in Attributes in C# but not on actual methods. I'm going to
love this.<br /><br />
VS2010 and C# will CTP are available in a <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=922B4655-93D0-4476-BDA4-94CF5F8D4814&amp;displaylang=en">virtual
PC here</a><br /><br />
Here's a better overview stolen from <a href="http://blogs.msdn.com/samng/archive/2008/10/28/microsoft-visual-studio-2010.aspx">http://blogs.msdn.com/samng/archive/2008/10/28/microsoft-visual-studio-2010.aspx<br /></a><blockquote><ol><li><strong>Dynamic binding. </strong>We've introduced a new type, <font face="courier new">dynamic</font>,
which behaves much like <font face="courier new">object</font>, but allows the operations
performed on your object to be bound at runtime instead of compile time.</li><li><strong>Named and Optional parameters. </strong>You can now specify default values
for your parameters, allowing them to be optionally specified at the call site. We've
also added the ability for your arguments to be passed by name, so that you can specify
exactly which arguments you want to give, and refrain from specifying the rest (assuming
they're optional).</li><li><strong>Com interop features. </strong>We've done quite a bit of work to improve COM
interop. These include:</li></ol><ul><li><strong>No ref for COM calls.</strong> For all COM calls that take ref arguments,
you can specify an argument without a ref, and the compiler will generate a local
for you and generate a ref to that local as the argument.</li><li><strong>No PIA. </strong>We have introduced the ability to deploy your applications
which use Primary Interop Assemblies (PIAs) without referencing the actual PIA at
runtime. This allows compiling against them, but not needing to ship them with your
application.</li><li><strong>Implicit dynamic for COM types. </strong>We now give you the option of turning
all <font face="courier new">object</font>s returned from COM into <font face="courier new">dynamic</font>s
so that you can perform late bound calls off of them instead of having to cast the
result in order to make it useful.</li></ul></blockquote><br /><p></p><img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=6af08b32-a592-4086-b634-04bce5effdb3" /></body>
      <title>PDC Announcements Day 1</title>
      <guid isPermaLink="false">http://blog.j-maxx.net/PermaLink,guid,6af08b32-a592-4086-b634-04bce5effdb3.aspx</guid>
      <link>http://blog.j-maxx.net/2008/10/28/PDCAnnouncementsDay1.aspx</link>
      <pubDate>Tue, 28 Oct 2008 01:03:34 GMT</pubDate>
      <description>Well I spent most of the day working on some peculiar problems with PICK. Then left to take my girlfriend out for her birthday. Just now catching up on whats gone on today at PDC. Man it seems like it was a huge day.&lt;br&gt;
&lt;br&gt;
First off Windows Azure and the new .NET Services. From what I've read so far I can
see some compelling uses for the .NET services and sharing content, id's and roles
around the web. 
&lt;br&gt;
&lt;br&gt;
The big one that I haven't seen much press on yet is C# 4.0. Looks like we are getting
dynamic binding in the language. While this loses compile type safety it gives C#
good ground against things like Ruby and PHP.&lt;br&gt;
&lt;br&gt;
Named, Optional and Default parameters. Oh how I've been waiting for these since switching
to .NET from PHP. I used to take advantage of these features all the time. It annoys
me when I can use them in Attributes in C# but not on actual methods. I'm going to
love this.&lt;br&gt;
&lt;br&gt;
VS2010 and C# will CTP are available in a &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=922B4655-93D0-4476-BDA4-94CF5F8D4814&amp;amp;displaylang=en"&gt;virtual
PC here&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
Here's a better overview stolen from &lt;a href="http://blogs.msdn.com/samng/archive/2008/10/28/microsoft-visual-studio-2010.aspx"&gt;http://blogs.msdn.com/samng/archive/2008/10/28/microsoft-visual-studio-2010.aspx&lt;br&gt;
&lt;/a&gt;&lt;blockquote&gt; 
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic binding. &lt;/strong&gt;We've introduced a new type, &lt;font face="courier new"&gt;dynamic&lt;/font&gt;,
which behaves much like &lt;font face="courier new"&gt;object&lt;/font&gt;, but allows the operations
performed on your object to be bound at runtime instead of compile time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Named and Optional parameters. &lt;/strong&gt;You can now specify default values
for your parameters, allowing them to be optionally specified at the call site. We've
also added the ability for your arguments to be passed by name, so that you can specify
exactly which arguments you want to give, and refrain from specifying the rest (assuming
they're optional).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Com interop features. &lt;/strong&gt;We've done quite a bit of work to improve COM
interop. These include:&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No ref for COM calls.&lt;/strong&gt; For all COM calls that take ref arguments,
you can specify an argument without a ref, and the compiler will generate a local
for you and generate a ref to that local as the argument.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No PIA. &lt;/strong&gt;We have introduced the ability to deploy your applications
which use Primary Interop Assemblies (PIAs) without referencing the actual PIA at
runtime. This allows compiling against them, but not needing to ship them with your
application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implicit dynamic for COM types. &lt;/strong&gt;We now give you the option of turning
all &lt;font face="courier new"&gt;object&lt;/font&gt;s returned from COM into &lt;font face="courier new"&gt;dynamic&lt;/font&gt;s
so that you can perform late bound calls off of them instead of having to cast the
result in order to make it useful.&lt;/li&gt;
&lt;/ul&gt;
&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=6af08b32-a592-4086-b634-04bce5effdb3" /&gt;</description>
      <comments>http://blog.j-maxx.net/CommentView,guid,6af08b32-a592-4086-b634-04bce5effdb3.aspx</comments>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://blog.j-maxx.net/Trackback.aspx?guid=91c07bc0-93a3-45b6-a0fd-de18c57fdc94</trackback:ping>
      <pingback:server>http://blog.j-maxx.net/pingback.aspx</pingback:server>
      <pingback:target>http://blog.j-maxx.net/PermaLink,guid,91c07bc0-93a3-45b6-a0fd-de18c57fdc94.aspx</pingback:target>
      <dc:creator>Jeff Klawiter</dc:creator>
      <wfw:comment>http://blog.j-maxx.net/CommentView,guid,91c07bc0-93a3-45b6-a0fd-de18c57fdc94.aspx</wfw:comment>
      <wfw:commentRss>http://blog.j-maxx.net/SyndicationService.asmx/GetEntryCommentsRss?guid=91c07bc0-93a3-45b6-a0fd-de18c57fdc94</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">The company I work for, Sierra Bravo Corp,
got its start connecting legacy PICK systems to the modern world. They accomplished
this via a proprietary client-server protocol we internally call db_server (Official
name is SierraDBC or BravoConnecter). Sure there are other PICK connection technologies
out there none of them support multiple PICK systems and OS Platforms. Currently we
support : D3, Universe, UniData, JBase, MvBase and others I don't remember right now.<br /><br />
I maintain the .NET client library. It was originally a port of the Java library which
was a port of the COM library. It's come quite a long way since then. Recently we've
found the need for compression to be added for some of our client. One in particular
has many employees out in the field connecting via AirCards where bandwidth availability
can be a problem. On top of that the application needs to retrieve quite a bit of
real time data from the home office. Retrieving 2mb of client history is not unheard
of.<br /><br />
After the server developer added compression to the result stream I started working
on the client end. I figured it should be a snap. If we have compression turned on,
just pass in a DeflateStream (fed by the NetworkStream of the TcpClient connection)
to the StreamReader we already use to retrieve the results. 
<br /><br /><pre name="code" class="c#">StreamReader ResultReader;
if (IsConnectionTypeSet(ConnectionOptionTypes.EnableCompression))
{
    DeflateStream dfs = new DeflateStream(ns,CompressionMode.Decompress);
    ResultReader = new StreamReader(dfs, Encoding.ASCII, false);
}
else
{
    ResultReader = new StreamReader(ns, Encoding.ASCII, false);
}</pre>One
would think that's all that it would take, right?<br /><br />
I was sadly mistaken. I would receive an exception (System.IO.InvalidDataException:"Block
length does not match with its complement.") every time I would try to read from the
stream.<br /><br />
The issue lies in the use of zlib for the compressed stream. zlib and DEFLATE use
the same algorithm for compression. The difference is zlib sends two bytes of header
data. So all the answers I found were to pop off the first two bytes of the stream.<br /><pre name="code" class="c#">StreamReader ResultReader;
if (IsConnectionTypeSet(ConnectionOptionTypes.EnableCompression))
{
    DeflateStream dfs = new DeflateStream(ns,CompressionMode.Decompress);
    ResultReader = new StreamReader(dfs, Encoding.ASCII, false);
    ns.ReadByte();
    ns.ReadByte();
}
else
{
    ResultReader = new StreamReader(ns, Encoding.ASCII, false);
}</pre> This
worked just fine but I was annoyed about how ugly it looked. I needed to move that
ugliness out of there. So I wrote a ZlibStream class to do this for me. I made it
for only Decompressing streams since I didn't have the budget to go and actually implement
the zlib headers.<br /><br />
[ZlibStream.cs]<br /><pre name="code" class="c#">    /// &lt;summary&gt;
    /// Supports decompressing a DeflateStream created by the zlib library
    /// &lt;/summary&gt;
    class ZlibStream : DeflateStream
    {
        #region Fields

        private bool HasRead = false;

        #endregion

        #region Constructors
        /// &lt;summary&gt;
        /// Initiates ZlibStream in Decompress mode
        /// &lt;/summary&gt;
        /// &lt;param name="stream"&gt;One of the System.IO.Compression.CompressionMode values that indicates the action to take&lt;/param&gt;
        public ZlibStream(Stream stream)
            : base(stream, CompressionMode.Decompress)
        {

        }
        /// &lt;summary&gt;
        /// Initiates ZlibStream in Decompress mode
        /// &lt;/summary&gt;
        /// &lt;param name="stream"&gt;One of the System.IO.Compression.CompressionMode values that indicates the action to take&lt;/param&gt;
        /// &lt;param name="leaveOpen"&gt;true to leave the stream open; otherwise, false.&lt;/param&gt;
        public ZlibStream(Stream stream, bool leaveOpen)
            : base(stream, CompressionMode.Decompress, leaveOpen)
        {

        }
        #endregion

        #region Public Methods

        public override int Read(byte[] array, int offset, int count)
        {
            if (HasRead == false)
            {
                this.BaseStream.ReadByte();
                this.BaseStream.ReadByte();
                this.HasRead = true;
            }
            return base.Read(array, offset, count);
        }

        #endregion

    }</pre>As
you can see it is very simple. Since all the StreamReader does is call the Read method
I just needed to remove those bytes during the first pass.  This class is extremely
simple and limited in its functionality. Doing Asynchronous reads with BeginRead will
not work. I checked via reflector and it does not use the DeflateStream.Read method.
It handles the BaseStream's Read methods on its own. 
<br /><br />
The one thing I may need to expand is doing the popping of the two bytes. Currently
it's not checking to see if the stream has any bytes to read. So far in testing this
hasn't been a problem. I'm going to try and see if I can create a situation where
the bytes are not available initially. I have a suspicion that the ReadByte() waits
for a Byte to be available and errors out on the Timeout value<br /><br />
So my result is as elegant as can be<br /><pre name="code" class="c#">StreamReader ResultReader;
if (IsConnectionTypeSet(ConnectionOptionTypes.EnableCompression))
{
    ZlibStream dfs = new ZlibStream(ns);
    ResultReader = new StreamReader(dfs, Encoding.ASCII, false);
}
else
{
    ResultReader = new StreamReader(ns, Encoding.ASCII, false);
}</pre><br /><p></p><img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=91c07bc0-93a3-45b6-a0fd-de18c57fdc94" /></body>
      <title>DeflateStream and zlib</title>
      <guid isPermaLink="false">http://blog.j-maxx.net/PermaLink,guid,91c07bc0-93a3-45b6-a0fd-de18c57fdc94.aspx</guid>
      <link>http://blog.j-maxx.net/2008/09/19/DeflateStreamAndZlib.aspx</link>
      <pubDate>Fri, 19 Sep 2008 14:42:40 GMT</pubDate>
      <description>The company I work for, Sierra Bravo Corp, got its start connecting legacy PICK systems to the modern world. They accomplished this via a proprietary client-server protocol we internally call db_server (Official name is SierraDBC or BravoConnecter). Sure there are other PICK connection technologies out there none of them support multiple PICK systems and OS Platforms. Currently we support : D3, Universe, UniData, JBase, MvBase and others I don't remember right now.&lt;br&gt;
&lt;br&gt;
I maintain the .NET client library. It was originally a port of the Java library which
was a port of the COM library. It's come quite a long way since then. Recently we've
found the need for compression to be added for some of our client. One in particular
has many employees out in the field connecting via AirCards where bandwidth availability
can be a problem. On top of that the application needs to retrieve quite a bit of
real time data from the home office. Retrieving 2mb of client history is not unheard
of.&lt;br&gt;
&lt;br&gt;
After the server developer added compression to the result stream I started working
on the client end. I figured it should be a snap. If we have compression turned on,
just pass in a DeflateStream (fed by the NetworkStream of the TcpClient connection)
to the StreamReader we already use to retrieve the results. 
&lt;br&gt;
&lt;br&gt;
&lt;pre name="code" class="c#"&gt;StreamReader ResultReader;
if (IsConnectionTypeSet(ConnectionOptionTypes.EnableCompression))
{
    DeflateStream dfs = new DeflateStream(ns,CompressionMode.Decompress);
    ResultReader = new StreamReader(dfs, Encoding.ASCII, false);
}
else
{
    ResultReader = new StreamReader(ns, Encoding.ASCII, false);
}&lt;/pre&gt;One
would think that's all that it would take, right?&lt;br&gt;
&lt;br&gt;
I was sadly mistaken. I would receive an exception (System.IO.InvalidDataException:"Block
length does not match with its complement.") every time I would try to read from the
stream.&lt;br&gt;
&lt;br&gt;
The issue lies in the use of zlib for the compressed stream. zlib and DEFLATE use
the same algorithm for compression. The difference is zlib sends two bytes of header
data. So all the answers I found were to pop off the first two bytes of the stream.&lt;br&gt;
&lt;pre name="code" class="c#"&gt;StreamReader ResultReader;
if (IsConnectionTypeSet(ConnectionOptionTypes.EnableCompression))
{
    DeflateStream dfs = new DeflateStream(ns,CompressionMode.Decompress);
    ResultReader = new StreamReader(dfs, Encoding.ASCII, false);
    ns.ReadByte();
    ns.ReadByte();
}
else
{
    ResultReader = new StreamReader(ns, Encoding.ASCII, false);
}&lt;/pre&gt;&amp;nbsp;This
worked just fine but I was annoyed about how ugly it looked. I needed to move that
ugliness out of there. So I wrote a ZlibStream class to do this for me. I made it
for only Decompressing streams since I didn't have the budget to go and actually implement
the zlib headers.&lt;br&gt;
&lt;br&gt;
[ZlibStream.cs]&lt;br&gt;
&lt;pre name="code" class="c#"&gt;    /// &amp;lt;summary&amp;gt;
    /// Supports decompressing a DeflateStream created by the zlib library
    /// &amp;lt;/summary&amp;gt;
    class ZlibStream : DeflateStream
    {
        #region Fields

        private bool HasRead = false;

        #endregion

        #region Constructors
        /// &amp;lt;summary&amp;gt;
        /// Initiates ZlibStream in Decompress mode
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="stream"&amp;gt;One of the System.IO.Compression.CompressionMode values that indicates the action to take&amp;lt;/param&amp;gt;
        public ZlibStream(Stream stream)
            : base(stream, CompressionMode.Decompress)
        {

        }
        /// &amp;lt;summary&amp;gt;
        /// Initiates ZlibStream in Decompress mode
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="stream"&amp;gt;One of the System.IO.Compression.CompressionMode values that indicates the action to take&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="leaveOpen"&amp;gt;true to leave the stream open; otherwise, false.&amp;lt;/param&amp;gt;
        public ZlibStream(Stream stream, bool leaveOpen)
            : base(stream, CompressionMode.Decompress, leaveOpen)
        {

        }
        #endregion

        #region Public Methods

        public override int Read(byte[] array, int offset, int count)
        {
            if (HasRead == false)
            {
                this.BaseStream.ReadByte();
                this.BaseStream.ReadByte();
                this.HasRead = true;
            }
            return base.Read(array, offset, count);
        }

        #endregion

    }&lt;/pre&gt;As
you can see it is very simple. Since all the StreamReader does is call the Read method
I just needed to remove those bytes during the first pass.&amp;nbsp; This class is extremely
simple and limited in its functionality. Doing Asynchronous reads with BeginRead will
not work. I checked via reflector and it does not use the DeflateStream.Read method.
It handles the BaseStream's Read methods on its own. 
&lt;br&gt;
&lt;br&gt;
The one thing I may need to expand is doing the popping of the two bytes. Currently
it's not checking to see if the stream has any bytes to read. So far in testing this
hasn't been a problem. I'm going to try and see if I can create a situation where
the bytes are not available initially. I have a suspicion that the ReadByte() waits
for a Byte to be available and errors out on the Timeout value&lt;br&gt;
&lt;br&gt;
So my result is as elegant as can be&lt;br&gt;
&lt;pre name="code" class="c#"&gt;StreamReader ResultReader;
if (IsConnectionTypeSet(ConnectionOptionTypes.EnableCompression))
{
    ZlibStream dfs = new ZlibStream(ns);
    ResultReader = new StreamReader(dfs, Encoding.ASCII, false);
}
else
{
    ResultReader = new StreamReader(ns, Encoding.ASCII, false);
}&lt;/pre&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=91c07bc0-93a3-45b6-a0fd-de18c57fdc94" /&gt;</description>
      <comments>http://blog.j-maxx.net/CommentView,guid,91c07bc0-93a3-45b6-a0fd-de18c57fdc94.aspx</comments>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://blog.j-maxx.net/Trackback.aspx?guid=fd9e969a-cf6b-406a-bddd-d434264d4fe1</trackback:ping>
      <pingback:server>http://blog.j-maxx.net/pingback.aspx</pingback:server>
      <pingback:target>http://blog.j-maxx.net/PermaLink,guid,fd9e969a-cf6b-406a-bddd-d434264d4fe1.aspx</pingback:target>
      <dc:creator>Jeff Klawiter</dc:creator>
      <wfw:comment>http://blog.j-maxx.net/CommentView,guid,fd9e969a-cf6b-406a-bddd-d434264d4fe1.aspx</wfw:comment>
      <wfw:commentRss>http://blog.j-maxx.net/SyndicationService.asmx/GetEntryCommentsRss?guid=fd9e969a-cf6b-406a-bddd-d434264d4fe1</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">Over the weekend I started Reading "<a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FCLR-via-Second-Pro-Developer%2Fdp%2F0735621632&amp;tag=jmaxxnet-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=9325">CLR
Via C#</a><img src="http://www.assoc-amazon.com/e/ir?t=jmaxxnet-20&amp;l=ur2&amp;o=1" alt="" style="border: medium none  ! important; margin: 0px ! important;" width="1" border="0" height="1" />".
I picked it up at Borders earlier this year with a certification book. I was trying
to get more MCTS certs at the time and never ended up reading it. Also every time
I look at it I feel like it's that black box I'll never be able to understand. I realized
this is a bad attitude to have, so I opened it up and began reading. Instead of becoming
lost, I feel like some things are becoming found.<br /><br />
I realize I should have read this book right away. So far nothing has been entirely
over my head. I have had to reread some paragraphs due to sentences being heavy on
the the terms. Also the author "Jeff Richter" tries to use the correct CLR terms and
they sometimes clash with C# and general OO terms. An example is he uses "type" as
the term for a static class. 
<br /><br />
I've made it 11 chapters in and so far it has been full of those "so thats how that
works" and "thats good to know" moments. The biggest one so far has been the Events
chapter. He covers a C# feature that has not been covered in any of the C# books I
have read. 
<br /><br />
In C# you can declare Events like Properties. That is instead of using "get" and "set"
blocks, one can use "add" and "remove" blocks. He covers this because the default
implementation of events in the CLR is a bit flawed when it comes to thread safety.
The CLR will lock the full object when adding and removing event delegates. He gives
an example of overcoming these flaws by implementing manual locking in the "add" and
"remove" blocks.<br /><br /><pre name="code" class="c#">private event EventHandler&lt;SomeEventArgs&gt; somethingHappend;
private Object mLock = new Object();
public event EventHandler&lt;SomeEventArgs&gt; SomethingHappend
{
    add
    {
        lock (mLock)
        {
            this.somethingHappend += value;
        }
    }
    remove
    {
        lock (mLock)
        {
            this.somethingHappend -= value;
        }
    }
}</pre>As
you can see it looks much like a C# property. It uses a private event that is exposed
publically through two blocks. Other than the keywords the other major difference
is you cannot set access modifers on the "add" and "remove" blocks. It would be very
bad programming to let someone add an event delegate but not let them remove it.<p></p><p>
I have one application that I maintain where this will come in very handy. Planning
on testing out the difference very soon.
</p><p>
I highly recommend this book for any serious .NET developer. I kick myself for not
learning more about the CLR in the first place. Visual Studio sometimes babies the
programmer too much I think. That and many programmers are lazy and love to just know
enough to get by. I find these kinds of programmers have a very hard time working
at Sierra Bravo. We have such a large variety of projects that one must learn quickly
and know enough to jump the entire gammut of .NET applications. As a .NET developer
here it's impossible to just be an ASP.NET developer or WinForms developer. I like
it that way, it ensures that I'm never board and am learning all the time.
</p><p>
In my tenure so far I have written, Winforms Applications, entire .NET CF warehouse
management applications, fully globalized ASP.NET web sites, various web services,
various windows services, System Tray utilities, a Vending Machine controller program
(implementing various serial protocols), written TCP clients for propietary protocols
and much more. I have also helped companies migrate to/from MSSQL databases with various
front ends. Heck, I'm even working on a C++ Win32 mobile application this week. I
have done more in 3 1/2 years than a typical programmer does in 10 years.<br /></p><p>
Understanding how something works makes it much easier to implement a project with
it. I found when I was a PHP programmer that I really went from amatuer to professional
when I studied how PHP parses the script, allocates memory for variables. This is
not an easy thing to do without looking at the source code. There are no good books
out there about the "PHP Runtime". Knowing the rammifications of taking advantage
of variable variables and not unsetting after use helped me take one of my more complext
php programs and reduce it's memory usage 3 fold. 
<br /></p><img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=fd9e969a-cf6b-406a-bddd-d434264d4fe1" /></body>
      <title>C# Event Declarations</title>
      <guid isPermaLink="false">http://blog.j-maxx.net/PermaLink,guid,fd9e969a-cf6b-406a-bddd-d434264d4fe1.aspx</guid>
      <link>http://blog.j-maxx.net/2008/08/11/CEventDeclarations.aspx</link>
      <pubDate>Mon, 11 Aug 2008 19:20:39 GMT</pubDate>
      <description>Over the weekend I started Reading "&lt;a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;amp;location=http%3A%2F%2Fwww.amazon.com%2FCLR-via-Second-Pro-Developer%2Fdp%2F0735621632&amp;amp;tag=jmaxxnet-20&amp;amp;linkCode=ur2&amp;amp;camp=1789&amp;amp;creative=9325"&gt;CLR
Via C#&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=jmaxxnet-20&amp;amp;l=ur2&amp;amp;o=1" alt="" style="border: medium none  ! important; margin: 0px ! important;" width="1" border="0" height="1"&gt;".
I picked it up at Borders earlier this year with a certification book. I was trying
to get more MCTS certs at the time and never ended up reading it. Also every time
I look at it I feel like it's that black box I'll never be able to understand. I realized
this is a bad attitude to have, so I opened it up and began reading. Instead of becoming
lost, I feel like some things are becoming found.&lt;br&gt;
&lt;br&gt;
I realize I should have read this book right away. So far nothing has been entirely
over my head. I have had to reread some paragraphs due to sentences being heavy on
the the terms. Also the author "Jeff Richter" tries to use the correct CLR terms and
they sometimes clash with C# and general OO terms. An example is he uses "type" as
the term for a static class. 
&lt;br&gt;
&lt;br&gt;
I've made it 11 chapters in and so far it has been full of those "so thats how that
works" and "thats good to know" moments. The biggest one so far has been the Events
chapter. He covers a C# feature that has not been covered in any of the C# books I
have read. 
&lt;br&gt;
&lt;br&gt;
In C# you can declare Events like Properties. That is instead of using "get" and "set"
blocks, one can use "add" and "remove" blocks. He covers this because the default
implementation of events in the CLR is a bit flawed when it comes to thread safety.
The CLR will lock the full object when adding and removing event delegates. He gives
an example of overcoming these flaws by implementing manual locking in the "add" and
"remove" blocks.&lt;br&gt;
&lt;br&gt;
&lt;pre name="code" class="c#"&gt;private event EventHandler&amp;lt;SomeEventArgs&amp;gt; somethingHappend;
private Object mLock = new Object();
public event EventHandler&amp;lt;SomeEventArgs&amp;gt; SomethingHappend
{
    add
    {
        lock (mLock)
        {
            this.somethingHappend += value;
        }
    }
    remove
    {
        lock (mLock)
        {
            this.somethingHappend -= value;
        }
    }
}&lt;/pre&gt;As
you can see it looks much like a C# property. It uses a private event that is exposed
publically through two blocks. Other than the keywords the other major difference
is you cannot set access modifers on the "add" and "remove" blocks. It would be very
bad programming to let someone add an event delegate but not let them remove it.&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
I have one application that I maintain where this will come in very handy. Planning
on testing out the difference very soon.
&lt;/p&gt;
&lt;p&gt;
I highly recommend this book for any serious .NET developer. I kick myself for not
learning more about the CLR in the first place. Visual Studio sometimes babies the
programmer too much I think. That and many programmers are lazy and love to just know
enough to get by. I find these kinds of programmers have a very hard time working
at Sierra Bravo. We have such a large variety of projects that one must learn quickly
and know enough to jump the entire gammut of .NET applications. As a .NET developer
here it's impossible to just be an ASP.NET developer or WinForms developer. I like
it that way, it ensures that I'm never board and am learning all the time.
&lt;/p&gt;
&lt;p&gt;
In my tenure so far I have written, Winforms Applications, entire .NET CF warehouse
management applications, fully globalized ASP.NET web sites, various web services,
various windows services, System Tray utilities, a Vending Machine controller program
(implementing various serial protocols), written TCP clients for propietary protocols
and much more. I have also helped companies migrate to/from MSSQL databases with various
front ends. Heck, I'm even working on a C++ Win32 mobile application this week. I
have done more in 3 1/2 years than a typical programmer does in 10 years.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
Understanding how something works makes it much easier to implement a project with
it. I found when I was a PHP programmer that I really went from amatuer to professional
when I studied how PHP parses the script, allocates memory for variables. This is
not an easy thing to do without looking at the source code. There are no good books
out there about the "PHP Runtime". Knowing the rammifications of taking advantage
of variable variables and not unsetting after use helped me take one of my more complext
php programs and reduce it's memory usage 3 fold. 
&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=fd9e969a-cf6b-406a-bddd-d434264d4fe1" /&gt;</description>
      <comments>http://blog.j-maxx.net/CommentView,guid,fd9e969a-cf6b-406a-bddd-d434264d4fe1.aspx</comments>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://blog.j-maxx.net/Trackback.aspx?guid=e4e4b464-2924-4671-849e-f064ea605229</trackback:ping>
      <pingback:server>http://blog.j-maxx.net/pingback.aspx</pingback:server>
      <pingback:target>http://blog.j-maxx.net/PermaLink,guid,e4e4b464-2924-4671-849e-f064ea605229.aspx</pingback:target>
      <dc:creator>Jeff Klawiter</dc:creator>
      <wfw:comment>http://blog.j-maxx.net/CommentView,guid,e4e4b464-2924-4671-849e-f064ea605229.aspx</wfw:comment>
      <wfw:commentRss>http://blog.j-maxx.net/SyndicationService.asmx/GetEntryCommentsRss?guid=e4e4b464-2924-4671-849e-f064ea605229</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Documenting code is one of those things
that programmers tend to leave out while under a tight dealine or just building a
new project. It's one of those things we tend to say, if we have time when we're done
we can do it. It can be time consuming and sometimes hard to see the benefit up front.
I'm very guilty of poor documentation and commenting. I rarely get to work in a team
so I always end up relying on my own memory for what does what and where. Then two
years go by and I forget it all.<br /><br />
I have been trying to get better about adding at least XML comments to my classes,
methods and properties. The project I am on right now is a rather large project due
in less than a month and so far we have a semi-concrete middle layer, a half mocked
up front end and a half done back end. We need more than just one or two people on
the project and I've been in charge of part of the back end and all of the middle
layer. Even though it is taking a bit more time I've been trying to add documentation
and actually use Unit Tests for my first time. (that's a whole other entry).<br /><br />
While the built in XML Commenting system C# has is great and can really help a programmer
when coding there is little to no good way of taking that and making separate documentation
out of it. That and editing it can be a real pain. After pouring over the web for
some way of exporting the XML as a CHM or MSDN type library I came across <a href="http://www.codeplex.com/DocProject">DocProject</a> .
This wonderfully free and open source VS 2005/2008 Addin is a godsend on this front.
It can create a standalone CHM or give you an MSDN library to integrate with your
VS or create a web project that has a decent Ajax interface for browsing the documentation
online. All export options can be done at once as well.<br /><br />
DocProject lets you edit every part of the XML Documenation in a rich text editor.
While I think the editor could use a bit of work (make it easier for putting code
in the Example and other regions code can exist) it does a great job of making it
much easier to write the documentation instead of just in code.<br /><br />
DocProject does have a bit of a draw back in it's requirements. To use it you must
install <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E82EA71D-DA89-42EE-A715-696E3A4873B2&amp;displaylang=en">Sandcastle</a>,
which isn't to large. If you want to output in the new Compiled HTML 2.x format you
need to install the VS 2008 SDK. The SDK however is nearly 100MB. Though I'd recommend
having it anyway, with it you get the ability to write VS addins and other fun stuff.<br /><br />
I just started using DocProject today, so far I'm impressed and I hope it turns out
to be a good addition to the development process of this project. I'm hoping to use
DocProject's publish features to put the documentation on a site where other developers
for the project will be able to reference. I've found over the years that the projects
with the most documentation end up being the easiest to work on.<br /><p></p><img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=e4e4b464-2924-4671-849e-f064ea605229" /></body>
      <title>Project Documenting under a deadline</title>
      <guid isPermaLink="false">http://blog.j-maxx.net/PermaLink,guid,e4e4b464-2924-4671-849e-f064ea605229.aspx</guid>
      <link>http://blog.j-maxx.net/2008/06/30/ProjectDocumentingUnderADeadline.aspx</link>
      <pubDate>Mon, 30 Jun 2008 01:57:50 GMT</pubDate>
      <description>Documenting code is one of those things that programmers tend to leave out while under a tight dealine or just building a new project. It's one of those things we tend to say, if we have time when we're done we can do it. It can be time consuming and sometimes hard to see the benefit up front. I'm very guilty of poor documentation and commenting. I rarely get to work in a team so I always end up relying on my own
memory for what does what and where. Then two years go by and I forget
it all.&lt;br&gt;
&lt;br&gt;
I have been trying to get better about adding at least XML comments to my classes,
methods and properties. The project I am on right now is a rather large project due
in less than a month and so far we have a semi-concrete middle layer, a half mocked
up front end and a half done back end. We need more than just one or two people on
the project and I've been in charge of part of the back end and all of the middle
layer. Even though it is taking a bit more time I've been trying to add documentation
and actually use Unit Tests for my first time. (that's a whole other entry).&lt;br&gt;
&lt;br&gt;
While the built in XML Commenting system C# has is great and can really help a programmer
when coding there is little to no good way of taking that and making separate documentation
out of it. That and editing it can be a real pain. After pouring over the web for
some way of exporting the XML as a CHM or MSDN type library I came across &lt;a href="http://www.codeplex.com/DocProject"&gt;DocProject&lt;/a&gt; .
This wonderfully free and open source VS 2005/2008 Addin is a godsend on this front.
It can create a standalone CHM or give you an MSDN library to integrate with your
VS or create a web project that has a decent Ajax interface for browsing the documentation
online. All export options can be done at once as well.&lt;br&gt;
&lt;br&gt;
DocProject lets you edit every part of the XML Documenation in a rich text editor.
While I think the editor could use a bit of work (make it easier for putting code
in the Example and other regions code can exist) it does a great job of making it
much easier to write the documentation instead of just in code.&lt;br&gt;
&lt;br&gt;
DocProject does have a bit of a draw back in it's requirements. To use it you must
install &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E82EA71D-DA89-42EE-A715-696E3A4873B2&amp;amp;displaylang=en"&gt;Sandcastle&lt;/a&gt;,
which isn't to large. If you want to output in the new Compiled HTML 2.x format you
need to install the VS 2008 SDK. The SDK however is nearly 100MB. Though I'd recommend
having it anyway, with it you get the ability to write VS addins and other fun stuff.&lt;br&gt;
&lt;br&gt;
I just started using DocProject today, so far I'm impressed and I hope it turns out
to be a good addition to the development process of this project. I'm hoping to use
DocProject's publish features to put the documentation on a site where other developers
for the project will be able to reference. I've found over the years that the projects
with the most documentation end up being the easiest to work on.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=e4e4b464-2924-4671-849e-f064ea605229" /&gt;</description>
      <comments>http://blog.j-maxx.net/CommentView,guid,e4e4b464-2924-4671-849e-f064ea605229.aspx</comments>
      <category>C#</category>
      <category>Documentation</category>
    </item>
    <item>
      <trackback:ping>http://blog.j-maxx.net/Trackback.aspx?guid=b8a75abb-b9d6-405f-a5d0-d5160dacbadb</trackback:ping>
      <pingback:server>http://blog.j-maxx.net/pingback.aspx</pingback:server>
      <pingback:target>http://blog.j-maxx.net/PermaLink,guid,b8a75abb-b9d6-405f-a5d0-d5160dacbadb.aspx</pingback:target>
      <dc:creator>Jeff Klawiter</dc:creator>
      <wfw:comment>http://blog.j-maxx.net/CommentView,guid,b8a75abb-b9d6-405f-a5d0-d5160dacbadb.aspx</wfw:comment>
      <wfw:commentRss>http://blog.j-maxx.net/SyndicationService.asmx/GetEntryCommentsRss?guid=b8a75abb-b9d6-405f-a5d0-d5160dacbadb</wfw:commentRss>
      <title>The blog hath arrived</title>
      <guid isPermaLink="false">http://blog.j-maxx.net/PermaLink,guid,b8a75abb-b9d6-405f-a5d0-d5160dacbadb.aspx</guid>
      <link>http://blog.j-maxx.net/2008/06/25/TheBlogHathArrived.aspx</link>
      <pubDate>Wed, 25 Jun 2008 00:25:49 GMT</pubDate>
      <description>Well I'm finally opening a real blog. Not sure how much I will be updating this but hey I have a real online presence again. The old J-Maxx Net will stay as it is. Still get a decent amount of traffic on there (kicking myself for not installing adsense years ago).&lt;br&gt;
&lt;br&gt;
To start off with.. I love LINQ. I've been looking into it for over a year now but
finally have a project where I get to use it fully. C# 3.0 has added so many features
I no longer pine for PHP as I once did. Here's a sample below of something I wrote
the other day.&lt;br&gt;
&lt;br&gt;
&lt;pre name="code" class="c#"&gt;
            var result = from c in CurrentDataContext.Categories
                         join localinfo in CurrentDataContext.CategoryLocalizationInfos
                            on c.CategoryID equals localinfo.CategoryID
                         where c.CategoryID == CategoryID
                         &amp;&amp; localinfo.Language == Language
                         select new Business.Data.Category()
                         {
                             ID = c.CategoryID,
                             Description = localinfo.Description,
                             Languages = GetLanguagesForCategory(c.CategoryID),
                             Name = c.Name,
                             SortOrder = c.SortOrder,
                             Title = localinfo.Title,
                             NavImage = c.NavImage,
                             Language = localinfo.Language,
                             Links = GetLinksForCategory(c.CategoryID, Language),
                             IsDataLoadedFromSql = true
                         };&lt;/pre&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.j-maxx.net/aggbug.ashx?id=b8a75abb-b9d6-405f-a5d0-d5160dacbadb" /&gt;</description>
      <comments>http://blog.j-maxx.net/CommentView,guid,b8a75abb-b9d6-405f-a5d0-d5160dacbadb.aspx</comments>
      <category>C#</category>
      <category>LINQ</category>
    </item>
  </channel>
</rss>