Dew Drop – December 25, 2011 (#1,227)

Ho ho ho!

Top Links

 

.NET / Visual Studio

 

Web Development

 

Design / Methodology / Testing

 

Silverlight / WPF / Windows Phone

 

Podcasts / Screencasts / Videos

 

Community / Events

 

Database

 

PowerShell

 

Miscellaneous

 

More Link Collections

 

The Geek Shelf

Node: Up and Running: Scalable Server-Side Code with JavaScript by Tom Hughes-Croucher

 

Dew Drop – December 23, 2011 (#1,226)

Next week’s Dew Drop posts will be a bit sporadic. I will be on vacation, enjoying some time at home with my family.

Top Links

 

.NET / Visual Studio

 

Web Development

 

Design / Methodology / Testing

 

Silverlight / WPF / Windows Phone

 

Podcasts / Screencasts / Videos

 

Community / Events

 

Database

 

PowerShell

 

Miscellaneous

 

More Link Collections

 

The Geek Shelf

Professional Android Programming with Mono for Android and .NET/C# by Wallace B. McClure

 

C# + ReSharper = Awesome: Tip #5 – Replace Constructor with Factory Method

This is the fifth in a series of quick how-to articles on ReSharper.

Tip #5 – Replace Constructor with Factory Method

Use: If an application must control how or when new instances of classes are created, a factory method can achieve this. ReSharper makes it simple to wrap a constructor with a static factory method.

Before
   1:      public class Car
   2:      {
   3:          private IList<IPart> _parts;
   4:   
   5:           public Car(IList<IPart> parts)
   6:           {
   7:               _parts = parts;
   8:           }
   9:      }
Right-click the constructor

image

Name your method or accept the default

SNAGHTML1ecbd865

After
   1:      public class Car
   2:      {
   3:          public static Car CreateCar(IList<IPart> parts)
   4:          {
   5:              return new Car(parts);
   6:          }
   7:   
   8:          private IList<IPart> _parts;
   9:   
  10:          private Car(IList<IPart> parts)
  11:           {
  12:               _parts = parts;
  13:           }
  14:      }

 

Happy coding!