Better way for debugging windows services

Saturday, January 28, 2006 12:00:00 AM (Central Standard Time, UTC-06:00)
For the longest time I was using System.Diagnostics.Debugger.Launch() with #If DEBUG compiler directive… this allows me to step into services when I am in debug mode. 
 
I found another approach while perusing MSDN the other day…  you can set the debugger to launch and attach automatically with out having code in your application to do so. 
 
 

Technology Previews Released in the last couple of days...

Wednesday, January 25, 2006 8:30:43 PM (Central Standard Time, UTC-06:00)

There has been a number of CTP's released in the last couple of days.  Yesterday I pointed out the WCF site, in addition to that there is also a new graphic design tool (code named Acrylic) for Windows Vista applications.  The January 2006 CTP of the Microsoft Expression Interactive Designer is available as a download.

Visual Basic 9.0 Overview
Although I haven't spent much time with Visual Basic in the last year, I still like to see what kind of cool extentions they are adding for developer productivity.  They published an overview on MSDN.

Creating Large Files

Tuesday, January 24, 2006 12:00:00 AM (Central Standard Time, UTC-06:00)
Right now I am working on a extended version of the application updater block for a client, as part of the testing I needed to create some large files to test the download progress dialog.  It can actually be done pretty easily after spending a couple of minutes poking around the BCL.
 
System.IO.FileStream fs = new System.IO.FileStream(@"c:\test2.bin", System.IO.FileMode.Create);
fs.SetLength(1000000 * 1000); //creates about a gig
fs.Close();
 
Warning: Be care that you have enough space on your drive when you do this, you may run into some problems if you don’t.

Windows Communication Foundation (WCF) Site Released

Monday, January 23, 2006 12:00:00 AM (Central Standard Time, UTC-06:00)
Previously know as Indigo, the new WCF site has been announced. 
 

Treo 700w Smart Phone

Thursday, January 12, 2006 12:00:00 AM (Central Standard Time, UTC-06:00)
Last Thursday they released the Palm Treo 700w.  I ordered mine Thursday and got it this last Tuesday, and it is a great phone.  My brother picked one up Tuesday also while he was in Seattle for TechReady.  I really like the design and the fact that is a phone first and foremost.  The form factor is not real small, but you can carry it in a pocket with out feeling like you have brick in there. 
 
Internet access is fast and there is already hacks out there to use it as a modem to get high-speed access anywhere.  The site says it won't be out until January 17th, but if you look around some of the pda news groups there is a beta that works.
 
Finally a Windows Mobile has a great form factor.

The Foundation of Design Patterns

Thursday, January 12, 2006 12:00:00 AM (Central Standard Time, UTC-06:00)
Since the popularity of design patterns in the mid to late 90's I have bounced back and forth between learning them and just being aware of them.  I bought a Java based book (Head First Design Patterns) on a recommendation of a friend (Ed Ferron) of mine last summer.  
 
I spent the next couple of weeks perusing through it.  One thing that dawned on me was that all design patterns have the core principals that many of us use everyday (or should use) to design and write software.  Forget the names for right now… all of these named/referenced patterns are based on core principals.  Many of these concepts have become engrained in how we do stuff.  The founders of design patterns combine these principals to solve common problems, and then give them names for reference.  These principals are identified in different ways through out the book, but really aren't compiled into one area.  The compilation of these principals is as follows:

Use Abstraction 
  • Identify the aspects of your application that vary and separate them from what stays the same.
 
Interfaces
  • Program to an interface not an implementation.
 
Favor Composition Over Inheritance
  • Encapsulate a family of algorithms into their own set of classes.
    1. Allows you set behavior at run-time as long you program to an interface.
 
Dependency Inversion
  • Depend upon Abstractions. Do not depend upon concrete classes.
  • High Level Components should not depend on low level components, rather they should depend on abstractions.
 
Guidelines for following principle:
    1. No variable should hold a reference to the concrete class.
    2. No class should derive from a concrete class (derive from an interface or abstract class).
    3. No method should override an implemented method of any of its base classes.  If you override, then your base class wasn't really an abstraction to begin with.  These methods are meant to be shared with your subclasses
       
Open/Closed Principles
  • Classes should be open for extension and closed for modification.
    1. Altering existing code that has been tested and is virtually bug free can be expensive.

Principle of Least Knowledge
  • When designing a class, be careful of the number of classes it interacts with.  There are a number of problems that arise if you are not careful.
    1. Creates heavy coupling among the implementation.
    2. Many dependencies create a fragile system that will be costly to maintain and complex for others to understand.
         
Guidelines for following principle:
  1. Only invoke methods on:
    • the object itself.
    • an object passed in as a parameter to the method.
    • any object the method creates or instantiates.
    • any components of the object.
       
Circular Dependencies   
  • Dependency rot happens when you have high-level components, depending on low-level components, depending on high-level components.
 
Guidelines for following principle:
  1. Low level components never call high level components.
  2. High level components determine when low level components are needed.          
     
Single Responsibility Principle
  • Classes should have only one reason to change.
  • Assign each responsibility to one and only one class.
 
Guidelines for following principle:
Classes that adhere to the principle tend to have high cohesion and are more maintainable then classes that take on multiple responsibilities.
 
High Cohesion --> a class designed around a set of related functions.
Low Cohesion --> a class designed around unrelated functions.
 
My point is… maybe I don't really have to memorize all of them… I can continue to just look them up when they come up in design reviews.  The key is to understanding the underlying principles they are based on and how those principles are accomplished.