Read the $##$%#@ Documentation!

A friend was recently writing code that needed to create email attachments based on text in a database, and the only way he could find to create the attachments from the text was to create a text file (see the constructors for the Attachment class). This bothered me, so I ripped out some code that would take the string, and convert it to a stream, so he could call the constructor for the Attachment class that accepts a Stream instance. I thought the code was useful, so I wrote a little article about it for Code Magazine (http://www.code-magazine.com/Article.aspx?quickid=0703121). I hate when I do this. I got an email yesterday, pointing out that again, I should perhaps do some research first:

I work a lot with attachments, and I thought your article was very well written.  However, it was also kind of un-neccesary.  There is a static function in the Attachment class

 

Attachment.CreateAttachmentFromString

 

that I believe would do everything in the article (while also being infinitely easier to maintain since its built in ). 

Ah, well. David A. Cohen sent the email, and he's completely correct. I guess it would have been a better plan to actually examine the members of the Attachment class before writing the code. A word to the wise: If you find yourself writing .NET code which seems like it sure as heck ought to have been included in the Framework, take a few seconds and try to convince yourself that it's not. Especially before you display your laziness in public! Sorry, folks.

Published Monday, March 19, 2007 7:41 AM by KenG

Comments

Monday, May 28, 2007 4:27 PM by Anthony

# re: Read the $##$%#@ Documentation!

RTFM!  :-)
Saturday, June 23, 2007 4:56 PM by Mark Freedman

# re: Read the $##$%#@ Documentation!

I just read your follow-up apology letter in the new issue of Code Magazine, and I can definitely understand how you feel, from a development point of view.  I have spent (wasted) time coding solutions that only required a single method call via an existing Framework class.

Don't feel too bad about it.  I, and many other people, have benefited greatly from your work (your articles and the awesome AppDev videos, etc.), and we all make these types of mistakes.