Wednesday, December 31, 2003


Roland Weigelt says:

There are many exciting .NET topics waiting for us in 2004. Simply too much stuff to be tried and understood, too much knowledge to be gained. If you're making plans for 2004, here's one single thing I can fully recommend:

If you're not already doing it, start writing unit tests using a test framework.

Unit testing is one of these "I really should be doing this" concepts. Even though I read and heard about unit testing years ago, I only started doing it in 2003. Sure, I always had some kind of test applications for e.g. a library - who hasn't written one of those infamous programs consisting of a form and dozens of buttons ("button1", "button2", ...), each starting some test code. And it's not as if my software was of poor quality. But looking back, unit testing was the thing in 2003 that made me a better developer.

I'm using NUnit for my unit tests; it's so easy to use that a typical reaction of developers being introduced to NUnit is "What? That's all I have to do?". To get started, visit this page on the NUnit website, and follow the steps in the first paragraph "Getting Started with NUnit".

When I began writing unit tests in early 2003, I wrote tests for existing code. If this code (e.g. a library) is already successfully in use, this can be pretty frustrating, because the most basic tests are all likely to succeed. My first tests where pretty coarse, testing too much at once - maybe because the trivial tests (e.g. create a class instance, set a property and test whether reading it has the expected result) seemed like a waste of time.

In the course of time I moved more towards "test driven development", i.e. writing tests along with the code, often even before the implementation is ready. Now, if I create a new project, I always add a test project to the solution. This way my code and the corresponding tests never run out of sync. If I make a breaking change, the solution won't compile - it's that easy.

If you take this approach (writing test very early), even testing the most basic stuff can be pretty rewarding:

  • Sometime typos or copy/paste mistakes are not caught by the compiler (e.g. when the property getter accesses a different member variable than the property setter) - one bug like this found by a unit test written in 5 Minutes can save you hours of debugging through a complete application.
  • It's a very good test for the usability e.g. of your API. If it turns out that even a simple task requires many lines of code, you definitely should re-design your API (which is less of a problem at that early stage of development).
  • The unit tests is some sort of documentation of how your code is used - don't underestimate how helpful this can be (by the way: I wrote a simple tool for generating examples for online documentation from unit tests).
  • Last but not least: I know that some of the unit-testing folks don't like debuggers, but fine-grained unit tests are very good entry points for single stepping through your code.

So... what about a New Year's Resolution to start writing unit tests?

[Weblogs @ ASP.NET]
1:12:48 PM    trackback []     Articulate [] 

Source: Jan Tielens' Bloggings

Announcing the ExtendedDataGrid: Adding essential functionality to the default Windows.Forms.DataGrid..

The default System.Windows.Forms.DataGrid provided by the .NET Framework is a little bit limited in functionality. Therefore I've spent some time during my holidays building an extension to this default grid: the ExtendedDataGrid. At this point I've released a Beta version: 0.1 including these features:

  • Image DataColumn
  • Formatted Text DataColumn
  • LinkLabel DataColumn
  • Calculated field DataColumn
  • ...

New features and probably bug fixes will come soon so if you have any comments, questions, remarks, ... please let me know. If you are intrested in the ExtendedDataGrid, you can monitor this RSS Feed of the latest news. I know all these features are available as sample, code snippet, article, ... on the web, but I just hated to implement some of them all of the time, for each project. Also, if you are planning to use this component, or if you are just intrested: let me know, your support will motivate me to make further improvements. :-)

Btw, happy new year to all of you!

[Jan Tielens' Bloggings]
1:01:04 PM    trackback []     Articulate [] 

Source: How to Save the World

OUR STORY.

birdIt's funny how things come together sometimes. Monday, after posting my advice column on blogging time-savers, and saying the most important thing is to get away from your computer and your reading and get out into the real world and give yourself time to think creatively about what really matters to you personally, I followed my own advice. Chelsea and I went for a long walk. And soon my head was filled with rage about all the things wrong with this world and the ten things that still keep me awake at night. And I wanted to know why they go on, ignored, uncorrected. Things happen the way they do for a good reason, I've always said. You need to understand why all this stuff has happened and continues to happen. Find the root cause, not the symptoms.

People love to read editorials and blogs that rant cleverly, emotionally and articulately, and blame other people for what's wrong. Pointing the finger at others exonerates us, takes the heat off, makes us feel better about ourselves. What's the root cause, and who's to blame?

And then I came back in and read some more of The Truth About Stories, the book I blogged about on Sunday so enthusiastically. And at the end of the book I found my story, perhaps our story, and all the rage I had focused outside was refocused inward, because this story is, at its root, a story of personal failure, cowardice and fear.

Here is what I read:

The truth about stories is that that's all we are. The Nigerian story-teller Ben Okri says that "in a fractured age, when cynicism is god, here is a possible heresy: we live by stories, we also live in them. One way or another we are living the stories that are planted in us early or along the way, or we are also living the stories we planted -- knowingly or unknowingly -- in ourselves. We live stories that either give our lives meaning or negate it with meaninglessness. If we change the stories we live by, quite possibly we change our lives."...

In North America, we talk about our environmental [and business] ethic. [We get outraged about incidents like the Exxon Valdez spill and the Enron fraud and demand action]. To listen to the noise generated by these two events, you would have thought that we cared. But in fact, we don't. Not in any ethical way. Oil tankers are supposed to be safe. Financial institutions are supposed to be bastions of integrity. But we do nothing to prevent such disasters from happening again. And when they do, and they surely will, our reaction will be the same, because the story we tell about moments like this is that they shouldn't have happened, that they're someone else's fault,...that there's no way to avoid them completely, that the environment and investor confidence will recover eventually...

The Canadian government closed down the East Coast cod fishery. The cod were already gone, had been going for years, and everyone knew it. The reason was simple. Overfishing. The fishers blamed the government. The government blamed the fishers, everyone blamed the large foreign offshore trawlers, seals, global warming, El Nino, Native people... Could such a thing have been prevented? Of course. So why didn't we prevent it?

The oil industry and our oil-based economy depend for their existence on the ability of geologists to find new fields of oil and our willingness to ignore the obvious, that at some point we're going to run out of oil. This would suggest that reducing energy consumption, curbing the proliferation of cars and multilane highways, and converting to sustainable sources of energy would be our first priorities. But we have no such priorities. We only hope that the exhaustion of the oil supply won't happen in our lifetime.

It's not that we don't care about ethical behaviour, the environment, society. It's just that we care more about our comfort and the things that make us comfortable -- property, prestige, power, appearance, security. And the things that insulate us from the vicissitudes of life. Money, for instance...

The proof of what we truly believe lies in what we do and not what we say. We've created the stories that allow [the ethics of what we do and don't do] to exist and flourish. They didn't come out of nowhere, from another planet. Want a different ethic? Tell a different story...

I weep for the world I've helped to create. A world in which I allow my intelligence and goodwill to be constantly subverted by my pursuit of comfort and pleasure. And because of knowing all of this, it is doubtful that given a second chance to make amends for my despicable behaviour, I would do anything different, for I find it easier to tell myself the story of my failure as a human being, than to have to live the story of making the sustained effort to help.

Our stories are lies. We know they are, but we keep telling them to ourselves and to each other. We keep living them and living in them. Thomas King acknowledges that this, The Truth about Stories, is in itself not a very satisfying story. "No plot. No neat ending. No clever turns of phrase." (The remaining stories in this book have all three, and are remarkable).

We don't want to hear the other stories out there in the real world -- the stories of what goes on inside the walls of abusive homes, factory farms, prisons, workplaces, schools, laboratories and institutions, and which are overtly played out in inner city streets and throw-away third world countries, the endless litany of violence, physical and psychological, personal and institutional, that occurs millions of times per minute throughout our world. These other stories detract from our 'comfort and pleasure'. They threaten to crack open the lies in our own story. That we cannot bear.

So the 'root cause' I was seeking during my walk with Chelsea is the subversion of our culture, this modern culture of negativism, acquisition, paternalism and scarcity whose ubiquitous, tyrannical story leaves everything in the hands of fate, or god, and absolves us of our responsibility and our sins, and fills us with the constant and consuming terror of not having enough. And we know who's to blame: The Man in the Mirror (that song was written, ironically, by a woman).

Our story is unfinished. We could change the ending if we want. Create a better ending. It's all up to us.

[My novel-in-progress will be an attempt to create a new ending, and perhaps a completely new story. I still hope to have it finished by the end of June.]
[How to Save the World]
12:20:21 PM    trackback []     Articulate []