private override

18Jan/070

Audience… #2

I started to write this bit on my previous post, but nixed it because I thought maybe it was just something that was going on in my head, but lo and behold, it at least happens to Jeremy Miller as well.

Before I get started, let me state that I do not claim to know everything about programming or even lots of things, and I am certainly not the best developer (no, I'm not saying I'm bad either!).  However I am willing to learn and am learning (LOTS), and thats all I can ask anyone else to do too.  Thats the only way we can progress to where we need to be.

The target I'm going for here is the code itself.

I write and design code at the highest level of technical ability that I can.  That means if a particular pattern makes sense, I'll use it.  If I can inject the dependencies in some way or another to make it testable, I'll do it.  I (try to) write my code as if I'm the audience.

Many people (I am guilty of this too), all too often try to write code that prevents the consumers of it from screwing stuff up.  I normally think this is just programmer paranoia, but I think it is a reasonable consideration.

I hate having to cater to the LCD in my code, but if I KNOW that Barney Fife's grandson, the programmer, (and he is not in my company) is going to be a consumer of my code, then I may 'dumb it down' so he doesn't end up screwing something up.  If he is part of my company, I'll take some responsibility and help him get to where he needs to be so he can better understand the concepts.

Its a careful consideration that, like the UI and usability experts of the world, we don't always get right.  What audience do you cater to when writing your code?

Filed under: Uncategorized No Comments
15Jan/072

Audience

It is funny how 'a-ha moments' happen at random times and on random topics.  The other day I was walking back from the water cooler at work, and doing some critical thinking as I was (yes!  I can do two things at once, even though Sandi doesn't think I can!).

Anyways, I had a realization of how when my English teachers in high school (thank you Mr. Stephens and Mrs. Baldwin) harped on the taget audience for a particular essay, that the topic audience isn't really specific to writing essays, it lends itself to many walks of life...  especially writing software. 

Many people talk about Microsoft always catering to the LCD (even Mark recently did!) and how the *nix community is usually the opposite.  The conversation usually (at least with tech-types) is that the level of control given by *nix is the right mix of simplicity and control.

Ahem... I beg to differ... or do I?

Maybe you'll think I'm just trying to walk the line (because you're mine?), but I don't think so.  I think it all depends on who you're trying to reach as to what 'denominator' you cater to.  Obviously its hard for Microsoft to hit it right, for example, with the Vista shutdown menu, when their target audience is EVERYONE.  That includes me, you, Grandma's, 5-year olds and anyone else.  It's easier for *nix to get it 'right', because they have a much more narrow audience.

I'll be the first to confess I have a heck of a time when designing the front-end of an app, and that is mostly due to audience.  Part of my job requires that I lay out new UI's when I add new functionality to our product.  Believe you me, I am no graphical designer or usability expert.  I usually want to lay it out and build as if I were using it... however, apparently engineers aren't the typical user-base of debt-collection software.  However, when I write tools (I am often times the Toolsmith for my team as well) that are meant for engineers, I have a completely different audience and an entirely different set of assumptions when laying out the UI that is much more native to my own.  It's a learning process, and I am definitely still on the climb up the curve.

Filed under: All, Tech 2 Comments
2Jan/070

Equality Assertions

I ran across a testing situation the other day when I needed to compare several properties on two objects, and assert that they were all equal.  In my next test, I wanted to assert that those same properties were all not equal.  I hate copying and pasting a list of properties to assert against, and just changing the method call from Assert.AreEqual to Assert.AreNotEqual.

The solution many might suggest is implementing the Equals method of my class.  However, this would be injecting code into my domain class that doesn't belong there since it doesn't get used in the application domain, only in the test domain, or it may already be implemented for its real domain use.  I don't see this as a viable solution.

My solution.  Since Assert.AreEqual and Assert.AreNotEqual have the same signature, we can create a delegate and pass the correct assertion method to a new method which we might call AssertProperties.  It might look something like the following:

[Test]
public void PropsAreEqual()
{
	Coder c1 = new Coder("jon", "fuller", "ruby");
	Coder c2 = new Coder("jon", "fuller", "c#");

	AssertProperties(c1, c2, new DAssertEquality(Assert.AreEqual));
}

[Test]
public void PropsAreNotEqual()
{
	Coder c1 = new Coder("jon" , "fuller"   , "ruby");
	Coder c2 = new Coder("mark", "garringer", "c#");

	AssertProperties(c1, c2, new DAssertEquality(Assert.AreNotEqual));
}

private void AssertProperties(Coder expected, Coder actual, DAssertEquality asserter)
{
	asserter(expected.FirstName, actual.FirstName);
	asserter(expected.LastName , actual.LastName );
}

Thanks Mark for lending me your name.  Anyone have a better solution?  Feel free to show me up!

Filed under: Uncategorized No Comments