TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

Framework Design Guidelines Book Arrived

My copy of Framework Design Guidelines by Krzysztof Cwalina and Brad Abrams arrived and so far I'm about 110 pages into it and find it very interesting. There's just something about annotations that you've gotta love, right? Brian Pepin so far has one of the most interesting ideas (or pattern): putting as much as possible in your abstract class, route overloads to a protected abstract method which allows you to write your argument checking code in one place if you want...

public abstract class FooBase {

    protected FooBase() {

    }

 

    public void DoSomething(int x, int y, string s, bool b) {

        DoSomethingImpl(x, y, s, b);

    }

 

    public void DoSomething(int x, int y, string s) {

        DoSomethingImpl(x, y, s, false);

    }

 

    public void DoSomething(int x, int y) {

        DoSomethingImpl(x, y, null, false);

    }

 

    protected abstract void DoSomethingImpl(int x, int y, string s, bool b);

}

 

public class Foo : FooBase {

    protected override void DoSomethingImpl(int x, int y, string s, bool b) {

        //do parameter checking here..

        if (b) ...

 

        if (s == null) ...

    }

}

There is a lot more interesting stuff in the book as well. Definitely buy a copy if you haven't already.


Digg!

posted on Tuesday, October 18, 2005 9:27 PM

Feedback

# re: Framework Design Guidelines Book Arrived 10/19/2005 6:48 AM Milan Negovan

It's interesting how after several years of devising patterns and and "best practices" in the traditional OO fashion, you see Microsoft advocate "test first" kind of design, i.e. designing APIs in a way that is easy to understand (even guess) and consume.

# re: Framework Design Guidelines Book Arrived 10/19/2005 9:07 AM Sean Chase

Agreed. I actually read a blog entry by Chris Sells a long time ago where he talked about how he started writing the code as an object model consumer *before* writing his OM. I started adopting that philosophy along with writing unit tests along with my code. It has worked out well. That being said, I think we've all made the mistake at one point or another of creating our OM first and then ending up with something that didn't quite work out the way we hoped and dreamed. :-)