>Humane Interfaces and Primitive Obsession

>

I just finished reading a blog post from Martin Fowler on Humane Interfaces.  Summed up the term simply means that an API is designed to be useful to a developer instead of being minimal and “legalistic” about what it should include (this is how _I_ understood the post).

I also read Chris Wheeler’s “My Favorite Smells” Primitive Obsession blog post yesterday and the while reading Martin’s post I had a small epiphany.

Based on Chris’s example of array indexes and the confusion over 1 or 0-based arrays, I thought, this would be a place where a Humane Interface could have solved the Primitive Obsession problem in a slightly different way.

Take a bunch of arrays that use a mixture of 0 and 1-based indexes.  Chris’s solution was to have a ZeroBasedInt and OneBasedInt that were used to index into the array.  My idea is that the array’s themselves could have simply had a First and Last property (or method).

The code would then simply be:

for (int i=myarray.First; i<=myarray.Last; i++)

{ // do something }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s