Amazon.com Widgets

Framework Design Guidelines: Powerful and Easy

Continuing in the series of sharing information from the Framework Design Guidelines

 

Expert from 2.2 Fundamental Principles of Framework Design

 

Providing a development platform that is both powerful and easy to use is

one of the main goals of the .NET Framework, and should be one of your

goals if you are extending it. The first version of the Framework indeed

gave developers a powerful set of APIs, but some of them found parts of

the Framework too difficult to use.

 

RICO MARIANI The flip side of this is that it must not only be easy to

use the API, but it must be easy to use the API in the best possible way.

Think carefully about what patterns you offer and be sure that the most natural

way to use your system gives results that are correct, is secure against

attacks, and has great performance. Make it hard to do things the wrong

way.

A few years ago I wrote this:

The Pit of Success: In stark contrast to a summit, a peak, or a journey

across a desert to find victory through many trials and surprises, we want

our customers to simply fall into winning practices by using our platform

and frameworks. To the extent that we make it easy to get into trouble we

fail.

True productivity comes from being able to easily create great products—

not from being able to easily create junk. Build a pit of success.

 

 

Rico really ups the ante here… as he makes very clear it is not sufficient that the API be easy to use, it must be easy to use in the right way… What APIs have you seen that are easy to use in the wrong way?

Published 07 October 05 01:56 by BradA

Comments

# Sean Chase said on October 7, 2005 6:16 PM:
throw new System.Exception("yuck");
# Matthew W. Jackson said on October 8, 2005 2:10 AM:
I'll second the Exception one. If you had it to do again, I'd say make System.Exception abstract, make all the exceptions that shouldn't be caught (such as ThreadAbortException or StackOverflowException) inherit from a single base (like AsyncException), and everything else could be a SystemException. Also, the ArgumentExceptions would be more consistant and useful.

Anyway, the big easy-to-misuse API I stumbled upon yesterday was Type.InvokeMember when late-binding COM objects. Specifically I'm talking about the "ParameterModifier[] modifiers" argument for marking arguments as by-reference. The usage of this is simply esoteric.

Then again, a lot of things in Reflection are this way.
# Jonathan Allen said on October 8, 2005 12:32 PM:
I for one have completely given-up on reflection. I need to use late binding because some COM classes are so poorly written that none of their interfaces appear to list all the methods I know exist.

Even though out company is mostly C#, we decided to write all the interop code in VB instead of dealing with the reflection directly.

For example, Rational's ClearQuest API. None of the interfaces listed in the object browser for the Entity object expose the EditEntity method. But yet VB somehow figures out how to call it anyways.

Can tell me how VB does that?

Jonathan
# Abubakar said on October 10, 2005 12:40 AM:
well I wrote a code using anonymous methods, and it was the only time I didnt like my code.
# Geert Baeyaert said on October 10, 2005 4:22 AM:
I think WeakReference.IsAlive is an example of a mountain of success.

Consider the following example:

foreach (WeakReference wr in wrs)
{
if (wr.IsAlive)
{
// GC happens here
((Foo)wr.Target).Bar();
}
}

Bam, NullReferenceException, hard to reproduce, hard to find.

Actually, I can't think of one example where WeakReference.IsAlive is usefull. You always have to check that the target is not null, as in the following example:

foreach (WeakReference wr in wrs)
{
Foo foo = (Foo)wr.Target;
if (foo != null)
{
foo.Bar();
}
}

Therefore, I think WeakReference.IsAlive should be made obsolete.

(I have already submitted this on the Feedback center, vote for it if you agree with me)
# I may have joined the wrong side said on June 28, 2006 2:47 PM:
The problem
Back when ASP.NET was first introduced, I had pretty high hopes that the new controls would...
# I may have joined the wrong side said on December 9, 2007 8:10 AM:

The problem Back when ASP.NET was first introduced, I had pretty high hopes that the new controls would

# Brad Abrams Framework Design Guidelines Powerful and Easy | Paid Surveys said on May 28, 2009 6:58 PM:

PingBack from http://paidsurveyshub.info/story.php?title=brad-abrams-framework-design-guidelines-powerful-and-easy

# Brad Abrams Framework Design Guidelines Powerful and Easy | internet marketing tools said on June 16, 2009 1:29 AM:

PingBack from http://einternetmarketingtools.info/story.php?id=7448

New Comments to this post are disabled

Search

Go

This Blog

Syndication

Page view tracker