CSharpFeeds - All your C# feeds in one place.

Sponsors

Tuesday, February 24, 2009

Framework Design Guidelines: Factored Types

by BradA via Brad Abrams on 2/24/2009 2:03:16 AM

Continuing in our weekly blog post series that highlights a few of the new image[5]_thumb[2]_thumb[2]_thumbadditions to the Framework Design Guidelines 2nd edition.. This content is found in the Factored Types section of Chapter 9: Common Design Patterns. Phil offers some great additions to the base pattern.

PHIL HAACK

Since Factored Types have an explicit lifetime, it probably makes good sense to implement the IDisposable interface so that developers can make use of the using statement. The code sample here could then be refactored to:

using(SerialPort port = new SerialPort("COM1")) {
  
port.Open();
  
GZipStream compressed;
  
compressed = new GZipStream(port.BaseStream,
      CompressionMode.Compress);
   
compressed.Write(data, 0, data.Length);
}

email it!bookmark it!digg it!

Original Post: Framework Design Guidelines: Factored Types

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us