Monday, 9 February 2009

Why TDD has the worst name ever

I've been listening to my favourite podcasts, HanselMinutes and .NetRocks, as usual and I've stumbled upon another gem of a show. It was about Test Driven Development. Why am I talking so much about this, although I don't practice it? Because I am sure I will get around and do practice it. It is not just a hype, it is the only way to do software. And I will explain why. But before that, let's talk about a confusion that has been cleared by the show I have been talking about.

The name Test Driven Development is usually associated with Automated Unit Testing. While this is mostly used only in TDD, it is not required by TDD at all. The badly chosen word Test actually means "meaningful, measurable, goals", in other words, the specifications! If you have those, you can test your application against the requirements and determine what is wrong, if anything. Without a clear view of the specs, you cannot tell if the project is performing as needed.

So if you think about TDD as Specifications Driven Development, you realize that you have been doing it all along! Admittedly, now it sounds even more like STD, but hey, sacrifices must be done in the name of improving code blog readability.

Now, I was saying that this is the only way to do software. Actually, I have explained why just above, but I will get into some personal details. I have been "blessed" with a project where the deadline was set before the specifications were drawn. Worse even, the specs did not come from people that really understand the business process, but from people using another piece of software that they want replaced. In other words, we're pretty much inventing ways of porting a badly designed Windows desktop app into ASP.Net. As this wasn't enough, we are also inventing features that were badly described by the client and starting from a partially functional ASP.Net project written by junior programmers.

What a drag! But that was actually not so bad as realizing that my developer output was slow, bad, and overall smelly and ugly. Why was that? Why couldn't I just stop whining and do what I know had to be done? Because there were no specs!. Without clearly drawn specs of not only what I had to do, but also what the initial project was supposed to do, my hands were tied. I could not refactor the code, because I had no way of telling if I broke anything. Has it ever happened to you to take a piece of code, make it better, then realize it is not working and you don't know why? The fear of that happening is the most important reason why people don't refactor. The next important factor being a manager that thinks refactoring is just a waste of time and has no vision of the future of the project.

But also, having no vision of what is to be done is the reason why developers are not motivated to do their job. Even the lowliest code monkey has to have a glimpse of the future of what they are doing, otherwise they are literally flying blind. Software development is just as much of an art as web design. It is actually strange that people don't understand there are many types of art just as there are many types of scientific thought. Even if we don't actually care how the app is gonna look as long as it does the job, we do feel pride in its functionality and it is nothing that hurts more as not knowing what that software is supposed to do and a clear way of measuring our own performance.

OK, enough of this. The bottom line is that a project needs to have clear specifications. The first test for a software is the compiler! You can even call it an automated test! ...but the last test is running through the spec list and determining if it does the job as required. Another podcast said that the process of creating automated tests has as a side effect the significant improvement of software quality, but not because of the tests themselves, but of the process of designing the tests. If your tests are meaningful, then you know what the app is to do and you have a clear vision of what failure and success mean and in the process of test design, you get to ask yourself the questions that lead to understanding the project. THAT is Test Driven Development!

Thursday, 5 February 2009

Pluto - a gem of a manga

Update: the manga is now completed, after 65 chapters. The ending was a bit disappointing, but at least it didn't drag on for ages like in other situations.

Atom, the strongest robot of all You can read Pluto, by Naoki Urasawa, up to chapter 62 on onemanga.com. It is updated often and I found it impossible to stop reading. The entire story is placed in a possible future where people and high intelligence robots coexist. There are only a few robots that have human like appearance and intelligence, and they are just beginning to understand feelings. A terrible killer is destroying them one by one, though. Who is he and what does he want?

I can hardly talk about the plot without spoiling it for you, but I can speak about my own impressions. Even if the logic/science in the series is not very consistent, the overall feeling is of great attention to detail, especially since the science is not as important as the philosophical perspective on consciousness and the soul. The drawing is also very carefully done and many of the slides are in color, as well. The plot is fascinating and it belongs to the group of stories the Japanese are so good at: the perils of too much power and the discovery of one's own limits.

I highly recommend this to lovers of manga and scifi alike. I will try to get the anime for Monster and I will probably get into reading the manga as well.

Tuesday, 3 February 2009

IE7 Pro - Internet Explorer addon

Update: There are some major issues with this addon, because on some sites (like YouTube, but not only) Internet Explorer simply closes with an error. It has become more and more annoying until I've decided to uninstall it.

What a nice little gem this is. I've just installed it, so I can't really say it is all good, but from what I've seen so far it is a wonderful addition to Internet Explorer (7 or 8!).

A few of the features that I've already observed:
  • It automatically recovers the pages and tabs opened when an computer or INTERNET explorer crash occurred.
  • Small download manager, FireFox style
  • Ad blocker - although it doesn't protect you from the javascript errors that occur when blocking ads
  • Mouse gestures
  • Background preloading of links when computer is idle enough and DNS prefetching
  • User scripts that can do all kinds of stuff, from moving YouTube windows where there is space and then showing them bigger to showing frames next to Google search results so you can open and preview the sites directly.
  • Tab history manager
.

But it does so much more. I am quite amazed by it. So get it, it's free: IE7Pro

Wednesday, 28 January 2009

Dogs

At first, I thought it was a coincidence, but it turns out it was all deliberate. This dog would come out from the park and then shit on the sidewalk. And not any kind of poop, but that smelly, sticky, yellow crap that only dogs seem able to manufacture. Then the dog would go back into the park, just far enough so that its presence would not be obvious, and it would watch. People would eventually step in the shit, all reacting to it in different ways. The ears of the dog would jump straight up, its eyes focused on the target, absorbing everything that happened.
He did that for three days in a row, so it couldn't have been a coincidence. However, when faced with the facts, they didn't seem so strange to me. Actually it makes perfect sense for predators to ambush their prey and learn from its behavior as much as possible. I admit, for a dog it was a pretty sick and smart thing to do, but it was all within reason. After all, I was doing the same thing, staking the man up, watching his every move, learning his habits.

I can remember the days when this filled me with excitement, the thrill of the hunt reverberating from some place deep inside my skull, but now I could only feel calm. Not boredom, though; boredom is dangerous, makes people sloppy, gets them hurt. I was missing a certain element, something that, in the past, made all this fun, but I couldn't quite find it now. That's why this was the last one. And only because it was necessary.

The guy showed up at exactly the time I was expecting him to do. Small time thug, acting cool while pretending to be larger than he was capable of ever being. I let him go up to his apartment, slightly amused at the concentrated look-around that he pretended to throw before entering the building. If he wouldn't have been pretending, he would have been able to notice me, watching him from a car for three days in a row. A different car, I admit, but who would be dumb enough to do it differently? Maybe the cops... and the guy was looking out for police presence, I guess. Unfortunately for him, I was no policeman.

I gave him 5 minutes to change his mind. Maybe he would feel the wrongness of the situation, maybe luck would be with him and make him leave for some reason. Maybe he would just grab a beer and drop in his big armchair, watching mind numbing TV shows, as I knew he would. Yet, I always like to allow for the unknown, for the unexplainable, makes it seem more real. Although, when doing this thing for a long time, one sees all kinds of shit and knows almost every way people react when stepping in it. I got out of my car.


I smashed the door lock with my foot and entered the room. Dirty, sloppy, typical bachelor room with a twinge of gangsta. What a dump! My guy froze for a second on his armchair, then, to my surprise, moved really fast and produced a revolver from underneath the small table next to him. He pointed it at me and shouted something along the lines of inquiring on my identity. Of course, a lot of "fuck" and "mudafucka" was involved, although that sounded a bit off coming from an oversized white guy.

I froze for a moment, too. A gun, who would have thought? I closed the door behind me, then turned to him and started telling him what had to be said. I did have three days to think it over in my head, after all.

"There is a saying", I calmly conversed, completely ignoring the vulgar threats coming from my target, " that every boy kills his father to become a man. Of course, it's a metaphor most of the time".

I waited for a reaction, watching how the feeling of control provided by the gun was slightly fading away. He decided to enforce it by standing up and aiming the gun at me from somewhere above his head, throwing profanities at me while doing so. Doesn't he know he can hurt his wrist by firing that way? Not to mention having almost no accuracy whatsoever.

"In other words, no man is complete without killing his father first, metaphorically speaking of course". It was almost hilarious; for a second, the guy thought I was talking about him and me. I could see on his face how he considered being my father or vice-versa. Well, at least not all of this will have been devoid of fun.

"Shut da fuck up, mudafucka! Who da fuck are you anyway? You escaped from some loony ... mental... "

I ignored him "However, it was you that actually killed my father. I therefore seem to be entitled to feel... incomplete.".
I could see the reaction right away. Killing one's father was a serious thing even for a brain dead thug. He knew he was in danger now, maybe he even felt guilty, even if he had no idea who my father was. He did take a step back and aimed the gun with both hands at me. Now, that was better. I could tell he was considering squeezing the trigger right then, but people are always too curious for their own good. He had to know how it plays out.

"I have decided to pursue my quest for completeness by killing you.", I then added, gently pushing him over the edge with a hard look. He fired.


There is something slightly poetic in having your own gun explode in your hands, killing you instantly with a stray piece of metal through the eye and brain. Of course, the cement in the barrel and the well planned weakening of the metal of the revolver cock would be obvious during the police investigation, but it would also be clear that the gun was unregistered and that the victim pulled the trigger voluntarily.

I didn't quite feel complete, though. He hadn't kill my father, either, so I guess it was to be expected, but I was sure he did kill someone's parent at some point in time, so I also expected a bit more gratification.

After all, it was a good call to stop doing this. No fun at all. Well, maybe not a complete stop, more like a sabbatical, to clear one's thoughts. I may never do it again.

Saturday, 24 January 2009

Monday, 19 January 2009

Seirei no Moribito - Guardian of the Sacred Spirit

the main characters in the story
Another pearl in the anime pond. One just has to dive and grab this fairy tale and watch it. Seirei no Moribito is the story of a female bodyguard, bound by honor and personal history to defend a child prince from the assassins sent by his father, the emperor. The anime is not really a fighting anime, though, no one battles for the sake of battle. More than that, the "ona yojimbo" has vowed to save lives, not take them, so she never kills anyone. All characters in the story are clearly drawn up, with their own particularities and personal motivations to do things and in the end, there is even a eco green moral. :)

My advice it to watch it, as it is both a beautiful story, as well as a complex one, fit for both adults and young children. Only 26 episodes, but it is worth it. I would really like to see animes for the rest of the books in the series. You can also read the first two chapters of the manga at Mangafox.

Friday, 16 January 2009

Including external javascript on async postbacks

Update: it has come to my attention that these kind of errors appear only when debug="true" in the web config. In production sites it might work regardless.

You want to programatically load a js in a user control. The user control becomes visible in the page only during async postbacks and it is hidden at page load. So you want to use some method of loading the external javascript file during that asynchronous UpdatePanel magic.

Use ScriptManager.RegisterClientScriptInclude. There is a catch, though. For each script that you want to include asynchronously, you must end it with
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
else the Ajax.Net script loader will throw an error like: Microsoft JScript runtime error: Sys.ScriptLoadFailedException:
The script '...' failed to load. Check for:
Inaccessible path. Script errors. (IE) Enable 'Display a notification about every script error' under advanced settings.
Missing call to Sys.Application.notifyScriptLoaded().
.

For the aspx version, use the ScriptManagerProxy control:
    <asp:ScriptManagerProxy runat="server">
<Scripts>
<asp:ScriptReference Path="~/js/myScript.js" NotifyScriptLoaded="true" />
</Scripts>
</asp:ScriptManagerProxy>