and has 0 comments
Long time since I posted a song on the blog. This is one old, but good song AND video. Rarely you find a truly good combination of sound and presentation nowadays. Quoting from the Wikipedia article for this song: Radiohead frontman Thom Yorke wrote the song about a narcissistic friend of his, which on closer inspection is showcased by the imagery in the lyrics - a parallel to earlier My Iron Lung EP track "Lewis [Mistreated]". He also says that it was somewhat of a competition between him and Jonny Greenwood to see who could fit the most chords into a song. "Just" is especially notable for Greenwood's guitar solo, which showcases some of his first uses of the Digitech Whammy Pedal. The guitar work in the song has been seen as an homage to post-punk band Magazine, one of Radiohead's key influences at the time.



The video reminds me of an old sci-fi story I've read about a word that, when heard by a person, would transform them into a purple jelly cone, including the one saying it. When someone finally understood and accepted the reality of it, it all turned into a race to stop a deaf person going to a radio station and speaking the word. He was immune, you see. Anyway, enjoy.

and has 0 comments

Science-fiction author Arthur C. Clarke is one of the people that has defined me as a person and who's books provided both comfort and excitement during my childhood and adolescence. He is mostly known for the movie adaptation of 2001: A Space Odyssey although I liked the Rama series more. He also invented the concept of a geo synchronous satellite. 
He has lived a full life and I don't believe in artificially prolonging living above a certain threshold (he was suffering for 13 years now), so I am just happy to have known about him rather than sad for his death.

More details at this BBC News article and this Wikipedia entry.

and has 0 comments
Ok, I will make a quick list and description. The rest is up to you.
  • Stargate Atlantis - the spinoff series of Stargate SG1 has ended its 4Th season, but a 5Th is under way. I am watching it mechanically now, as the quality and originality of the show has decreased in time to the point of negative values

  • Battlestar Galactica - another sci-fi show, it reinvented completely the story of the old 70's BattleStar Galactica. It started great, but the third season ended in some weird pseudo spiritual mambo jumbo. Hopefully, the fourth season due in April will not suffer from the 'Lost' disease

  • Doctor Who - British sci fi, a bit goofy, but fun nonetheless. It is about an alien that travels space and time with his human female companions (nothing kinky though ;) )

  • Eureka - silly sci-fi show about an American town that is populated only with brilliant scientists. Very far fetched, but nice as a light comedy. I haven't been able to finish season 2 that finished airing. I think there will be a season 3 as well.

  • Regenesis - a bit hard to catalogue, this Canadian sci-fi depicts a multinational scientific group with no political associations trying to fight the medical national emergencies in the world. All kinds of diseases and wacky characters, but a bit failing in the field of science. Season 4 is ongoing.

  • Jericho - now this is a series that was almost cancelled, then brought back at popular demand. Twelve American cities have been blown to smithereens by carefully planted nukes. The US quickly destroyed Iran and North Korea, but it seems the actual perpetrators are American. A small town in the US has to fight off both corporate conspiracies, the newly formed American government and the bands of bandits and neighbouring towns that want what Jericho has: a fan base :).

  • Numb3rs - oh, what a waste. It started so beautifully as a mathematician applying math to help his FBI agent brother. By season 3 it got completely unscientific, season 4 lost math completely and turned into yet another cop show.

  • Lost - I am not watching this anymore, only my wife does. I stopped watching this crap after the first season. Meanwhile they use the same psychological system to carry on a story that makes no sense and that everybody watches for the sole purpose of seeing it end. Like a modern day 1001 Arabian nights played on the audience. The only worth watching part of Lost is the pilot episode, then you should continue the story in your own way.

  • Grey's Anatomy - medical/soap opera. My wife watches it. It started a bit interesting, but ended up crappy. Almost no medicine anymore, instead you see the personal issues of various medical staff people.

  • Private Practice - as if Grey's Anatomy was not enough, they made a spinoff out of it. I don't know if it will ever air again, though, with the writer strike and all.

  • Ugly Betty - it proved a commercial success in Latin America, so the TV corporations cloned it for the US market. A gayified version of the South American show, it is basically a women magazine made TV series.

  • Prison Break - interesting beginning. I recommend the first season, then it all got 'Lost', with psychological effect to keep the audience interested, an escalation of tension, a complete disaster of a plot.

  • House MD - this one lasted a bit longer before turning to shit. It is a medical show that depicts a wacky, but brilliant diagnostician trying to figure out what the disease and cure is before the sick expires. It has become repetitive and self-satirical, moving away from medicine and back on the ugly and not interesting ploy of human relationships, but then it got back on track. Still worth watching, although the quality is dropping and the story grows old.

  • Criminal Minds - TV cop show with a team of FBI agents trying to find criminals by using behavioural analysis. Interesting enough, although, as you can imagine, not very technical.

  • Sarah Connor Chronicles - [chuckle] Terminator is not a teenage girl. She protects John Connor and his mother from other Terminators that roam freely in the past, yet keep a low profile for some reason or another. It's not terrible.

  • South Park - delicious animated gross comedy, making fun of everything and everybody. They lost the way around season 10, when the authors seemed buried in scandals and full of rage, unable to make fun of things, starting to instead vent frustration in the show. I am happy to see they have recovered in season 11 and season 12 has just started.

  • Dexter - a serial killer hunts serial killers. This makes him good, somehow, but he is still a killer. Funny enough his cop father taught him how to hide from the police, his sister doesn't know and she is a cop, too, and a colleague of Dexter, who is a criminal forensic in the police department.

  • Big Love - this is like a family in distress kind of show, but this time the family is made of one husband, 3 wives and numerous children I've lost count of. Yes, they are Mormons and they must navigate the perils of hiding their religion and marital arrangements from the rest of the world, while managing to obey or wriggle around the organisational structure of the Mormons in their community. As much a fascinating subject as this is, the show is pretty ordinary. Tom Hanks is an executive producer.


That's about it.

and has 0 comments
While in search for interesting and high quality podcasts I've stumbled upon escapepod.org, a site that offers free sci-fi stories in audio format. They last about 40 minutes, so just about the time it takes me to get from my home to work and they are great in both content and narration quality. It completely takes care of my needs when I get back home and I don't feel like listening to some tech podcast.

Even more, it seems that they post two or three books a week, so you won't finish the site right away. Great job, guys! A site truly after my own heart: exactly what you need, how you need it and with no annoying ads or marketing ploys.

and has 1 comment
As a software developer with no formal training, I sometimes feel humbled by the more standardised approaches to programming like, for example, Test Driven Development or TDD. But I think that today I finally figured it out.

You see, TDD is supposed to "cover your code" with tests. Once all your tests run without fail, you know that you can focus on other parts of the code, like refactoring, interface or performance improvements or on new features. But what it actually means is a simulation of your client and/or debug person. Once you automatically simulate a client, you can make sure it is satisfied before you move on to the real person. And this is also where the whole thing fails, because it is obviously impossible to simulate a human being without real effort that surpasses the building of the very software you are trying to test. It would be fun to actually do it, then watch the software complain on its own functionality. If any software is going to take over the world, one that emulates an annoying client probably will.

One of the hardest parts to simulate is the work with the interface. No test will ever be able to look disappointed while expressing a lack of enthusiasm on your choice of colors. It is even harder to test web interfaces, although software that can test some of the behaviour of web apps and sites exists, with limited functionality. Also, it is impossible to test for functionality that is not there.

A good use of tests is to address (and in this way document) the bug findings! When you see a bug, you create a test that fails because of it, then you fix the bug. Also, by trying to cover as much of your code with the tests, you get to formalize the access to your code and also are forced to decouple interface from code. No wonder that all the test frameworks are used for Unit Testing. Once you can create a unit or a library of code with no other inputs or outputs than data types, you can test the hell out of it.

But it still leaves the interface out. I have been thinking of ways of describing the test procedure not in code, but in English, something like a unit test for a person rather than a testing framework. This can be further automated, where possible, or just followed by a dedicated tester.

What I would really be interested in would be a general way of creating tests for recurring bugs. A sort of code policy enforcement, if you will, but one that would test for the same bug multiple applications. Can it be done without also formalising the structure of those applications?

A while ago I wrote a quick post to remind me of how to use the AutoCompleteExtender, but recently I realised that it was terribly incomplete (pun not intended). I've updated it, but I also felt that I need to restructure the whole post, so here it is, with more details and more code fun.

First of all, a short disclaimer: I am not familiar with the ASP.Net Ajax javascript paradigm. If some of the things that I am doing seem really stupid, it's because I did it by trial and error, not by understanding why the code is as it is. Here it goes.

There are two ways in which to use the AutoCompleteExtender: using PageMethods or using web service methods. The details are in the previous post, I will only list the gotchas in this one.
  • PageMethods requirements:
    1. ScriptManager must have EnablePageMethods="true"
    2. The page method must have the form public static string[] MethodName(string prefixText, int count) AND THE SAME PARAMETER NAMES. If you change prefixText with text it will not work!
    3. The page method has to be public and STATIC
    4. No, it is not possible to declare the method in a web user control, it must be in the page
  • Web service requirements:
    1. The method must have the form public string[] MethodName(string prefixText, int count) AND THE SAME PARAMETER NAMES. If you change prefixText with text it will not work!
    2. The method has to be public and NOT STATIC
    3. The method must be marked as ScriptMethod
.

Now, the method can return an array different from a string array, but the only useful types there would be numerical or maybe dates. Any object that you send will ultimately be transformed into "[object Object]". There is a way to send a pair of value,text encoded in the strings, and for that you use:
AutoCompleteExtender.CreateAutoCompleteItem(text, value);

It doesn't help much outside the fact that in the client javascript events of the AutoCompleteExtender the first parameter will be the AutoCompleteExtender javascript object and the second an object with a _text and a _value properties.

One of the questions I noticed frequently on the web is: How do I show the user that there are no auto complete matches?. The easy solution is always to return at least one string in the string array that your method is returning. If there are no matches, make sure there is a "No Match" string in the list. But then the complicated part comes along: how do you stop the user from selecting "No Match" from the list? And I do have a solution. It seems that the text in the textbox is set based on the existence of a javascript object called control that has a set_text function. If the object or the function do not exist, then a simple textbox.value=text is performed. So I used this code:

string script = @"var tb=document.getElementById('" + tbAutoComplete.ClientID + @"');if (tb) tb.control={set_text:setText,element:tb};";
ScriptManager.RegisterStartupScript(Page,Page.GetType(),UniqueID+"_init",script,true);
to set the object for my textbox. And also the javascript code that looks liks this:
function setText(input) {
if (input=='No Match') return;
this.element.value=input;
}


These being said, I think that one can use the AutoCompleteExtender and know what the hell is making it not work.

Update: The 30 September 2009 release of the AjaxControlToolkit doesn't have the error that I fix here. My patch was applied in July and from September on the bug is gone in the official release as well. Good riddance! :)

==== Obsolete post follows

I've just downloaded the 29 feb 2008 release of the AjaxControlToolKit and I noticed that the TabContainer bug that I fixed in one of the previous posts did not work anymore. So the post is now updated with the latest fix.

Fixing TabContainer to work with dynamic TabPanels

Apparently, the guys that make the Ajax Control Toolkit are not considering this a bug, since I posted it a long time ago as well as a bunch of other folks and there are also some discussions about it on some forums.

and has 5 comments
Well, imagine a lonely boy, without a family, learning magic in a special school and who's archenemy is a powerful yet evil wizard. He is always accompanied by his friends, a boy and a girl. The evil wizard likes snakes and manages to kill the headmaster of the magic school. No, it's not Harry Potter, it's Naruto!

It's like the Japanese liked Harry Potter, but thought they can do one better. They're not exactly magicians, but ninjas; Naruto Uzumaki, the main character, is a mix of both Harry and Ron, while boy number two, Sasuke Uchiha, is more like a small Snape. With a bit of a stretch, one could take the Naruto story and rip it off in a prequel to Harry Potter, with the parents as the characters :)

Anyway, long story short: the anime is children oriented, with all kind of soapy feelings, camaraderie and friendships, no gore, little blood, a bit of death, but "censored" where violence or tension is concerned. If you ignore the ridiculous simplicity of the characters, the story is pretty captivating and the "ninja science" fun. It more than makes up in quantity what it misses in quality. The first anime, Naruto, is concerned with the childhood of the characters and spans 220 episodes, while the ongoing Naruto: Shippūden with the adolescence and it is close to 50 episodes so far. There are 20 minutes episodes, if you count the 1.5 minutes presentation in, but don't worry, the fights last well into fourth episodes >:). Also, there are currently 4 Naruto movies: 3 for the first series and 1 for Shippūden.

Basically, if you cross Inuyasha with Harry Potter you get Naruto. I guess that any media industry, once it reaches a level of maturity, makes compromises in order to satisfy the greater audience. What Hollywood did for the US, the anime companies are doing for Japan, but in the end, the result is the same: dumbed down versions of what it could be.

Fortunately, animes are often based on manga publications and you can read Naruto well over the story arch in the anime, freely online.

Links:
Naruto Wikipedia
Naruto Manga Online
Naruto meets Harry Potter video

This blog post is about ASP.Net Ajax calls (Update panel and such), if you are interested in aborting jQuery.ajax calls, just call abort() on the ajax return object.

Kamal Balwani asked for my help on the blog chat today and asked for the solution for a really annoying issue. He was opening a window when pressing a button on an ASP.Net page and that window used web services to request data from the server repeatedly. The problem was when the window was closed and FireFox (the error did not appear on Internet Explorer) showed a 'Sys is not defined' error on this javascript line: _this._webRequest.completed(Sys.EventArgs.Empty);.

It was a silly error, really. There was this javascript object Sys.Net.XMLHttpExecutor and it had a function defined called _onReadyStateChange where a completed function received Sys.EventArgs.Empty as an argument. At that time, though, the page was unloaded as well as any objects defined in it. I consider this a FireFox bug, as any javascript function should not try to access an object that was unloaded already.

Anyway, going through the Microsoft Ajax library is a nightmare. I am sure they had clear patterns in mind when they designed it this way but for me it was a long waste of time trying to get my head around it. Finally I've decided that the only solution here was to abort the last Ajax request and so I've reached these two posts:

Cancel a Web Service Call in Asp.net Ajax
How to cancel the call to web service.

Bottom line, you need to use the abort function on a WebRequestExecutor object which one can get from using the get_executor function on a WebRequest object which should be returned by a scriptmethod call.

But you see, when you execute TestService.MyMethod you get no return value. What you need to do is use TestService._staticInstance.MyMethod which returns the WebRequest object required! Good luck figuring that out without Googling for it.

From then on the ride was smooth: add an array of web requests and at the window.onbeforeunloading event, just abort them all.

Here is the code for the popup window:

<body onload = "runMethod();" onbeforeunload = "KillRequests();">

function runMethod() {
   if (!window._webRequests) window._webRequests = Array();
   _webRequests[_webRequests.length]
      = TestService._staticInstance
        .MyMethod(OnSuccess, OnTimeout);
   }


function OnSuccess(result) {
   //do something with the result
   setTimeout(runMethod, 500);
   }


function OnTimeout(result) {
   setTimeout(runMethod, 500);
   }


function KillRequests() {
   if (!window._webRequests) return;
   for (var c = 0; c < window._webRequests.length; c++) {
      if (window._webRequests[c]) {
         var executor = window._webRequests[c].get_executor();
         if (executor.get_started()) executor.abort();
         }
      }
   }

A chat user asked me the other day of how does one put the tabs in the AjaxToolKit TabContainer vertically and I had no idea. I've decided to do it today and write this blog post, maybe he'll come back and he'd get the answer.

So, the request is simple: take a web site with a TabContainer in it and make it show the tabs vertically. I can only assume that the vertical tabs would go on the left and the content in the right. So I took the Internet Developer Toolbar and analysed the html output of a page with four static tabs. I added a <style> tag with CSS classes and started making changes until it worked. Unfortunately, the same setup would not work on Firefox, so I had to repeat the process using Firebug to analyse the page output. In the end this is the result:
<style>
.ajax__tab_header {
float:left;
}
.ajax__tab_body {
/*float:left;*/
margin-left:220px;
}
.ajax__tab_outer {
display:block !important;
}
.ajax__tab_tab{
/*min-width:200px;*/
width:200px;
height:auto !important;
}
</style>
.

Add this on top of your page or include it in your CSS and the tabs will appear vertically.

Now for a bit of explaining.
  • First of all this does not overwrite the CSS that the TabContainer loads because it is organized under a general ajax__tab_xp class like: .ajax__tab_xp .ajax__tab_header .
  • Then the width of 200px is arbitrary. I used it to keep the vertical tabs at the same width. I tried using min-width first, but it won't display right in Firefox.
  • Another point is about the ajax__tab_body class that I tried to set up first as float left, which would place the body div next to the tabs div, however this breaks if the body tab is wider and the content would appear underneath the tabs div. Thanks to my colleague Romeo I used the margin-left trick. 220px is enough to work in both IE and Firefox. It can be made smaller (closer to 200px)if the default IE body margin would be 0.
  • The !important keyword is placed to overwrite some settings that are already set up in the original TabContainer CSS.
  • Last issue: now the right panel will be truncated if it gets too large. You should control the overflow of that div, although, as far as I am concerned, my job is done


As a kind of disclaimer, I am not a CSS expert. If you know of a better way of doing this, please let me know.

I named this post so because I started researching something that a chat user asked me: how do you add UpdatePanels programatically to a page. You see, the actual problem was that he couldn't add controls to the UpdatePanel after adding it to the page and that was because the UpdatePanel is a templated control, in other words it contains one or more objects that inherit from ITemplate and all the control's children are part of these templates.

So, the required application is like this: A page that has a button that does nothing but a regular postback and another button that adds an UpdatePanel. Each update panel must contain a textbox and a button. When the button is pressed, the textbox must fill with the current time only in that particular UpdatePanel. If the regular postback button is pressed, the UpdatePanels must remain on the page.

What are the possible issues?
First of all, the UpdatePanels must survive postbacks. That means that you have to actually create them every time the page loads, therefore inside Page_Load. Note: we could add them in Page_Init and in fact that's where they are added when getting the controls from the aspx file of a page, but during Init, the ViewState is not accessable!
Then, there is the adding of the UpdatePanels. It is done in a Click event from a button, one that is done AFTER the Page_Load, therefore adding of an UpdatePanel must also be done there. Note: we could put the CreatePanels method in Page_LoadComplete, but then the controls in the update panel will not respond to any events, since the Load phase is already complete.
There is the matter of how we add the TextBox and the Button in each UpdatePanel. The most elegant solution is to use a Web User Control. This way one can visually control the content and layout of each UpdatePanel and also (most important for our application) add code to it!
Now there is the matter of the ITemplate object that each UpdatePanel must have as a ContentTemplate. This is done via the Page.LoadTemplate method! We you give it the virtual path to the ascx file and it returns an ITemplate. It's that easy!

Update:if you by any chance want to add controls programatically to the UpdatePanel, use the ContentTemplateContainer property of the UpdatePanel like this:
updatePanel.ContentTemplateContainer.Controls.Add(new TextBox());


Enough chit-chat. Here is the complete code for the application, the DynamicUpdatePanels page and the ucUpdatePanelTemplate web user control:
DynamicUpdatePanels.aspx.cs
using System;
using System.Web.UI;

public partial class DynamicUpdatePanels : Page
{
private int? _nrPanels;

public int NrPanels
{
get
{
if (_nrPanels == null)
{
if (ViewState["NrPanels"] == null)
NrPanels = 0;
else
NrPanels = (int) ViewState["NrPanels"];
}
return _nrPanels.Value;
}
set
{
_nrPanels = value;
ViewState["NrPanels"] = value;
}
}

protected void Page_Load(object sender, EventArgs e)
{
CreatePanels();
}

private void CreatePanels()
{
for (int i = 0; i < NrPanels; i++)
{
AddPanel();
}
}

private void AddPanel()
{
UpdatePanel up = new UpdatePanel();
up.UpdateMode = UpdatePanelUpdateMode.Conditional;
up.ContentTemplate = Page.LoadTemplate("~/ucUpdatePanelTemplate.ascx");
pnlTest.Controls.Add(up);
}

protected void btnAdd_Click(object sender, EventArgs e)
{
NrPanels++;
AddPanel();
}
}


DynamicUpdatePanels.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynamicUpdatePanels.aspx.cs"
Inherits="DynamicUpdatePanels" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>
Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Panel ID="pnlTest" runat="server">
</asp:Panel>
<asp:Button ID="btnAdd" runat="server" Text="Add Panel" OnClick="btnAdd_Click" />
<asp:Button ID="btnPostBack" runat="server" Text="Postback" />
</form>
</body>
</html>


ucUpdatePanelTemplate.ascx.cs
using System;
using System.Web.UI;

public partial class ucUpdatePanelTemplate : UserControl
{
protected void btnAjax_Click(object sender, EventArgs e)
{
tbSomething.Text = DateTime.Now.ToString();
}
}


ucUpdatePanelTemplate.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucUpdatePanelTemplate.ascx.cs"
Inherits="ucUpdatePanelTemplate" %>

<asp:TextBox ID="tbSomething" runat="server"></asp:TextBox>
<asp:Button ID="btnAjax" runat="server" OnClick="btnAjax_Click" />


That's it, folks!

and has 0 comments

Agile development is something of a growing software culture. Every dev team is trying to become agile. Programmers I know working like that are all happy and evangelizing the concept as the best thing since the fire simulation algorithm. The word is that Agile gives control back to the developer.

So, what does a code monkey have to do to become agile? (and no tree algorithm jokes here, please!). As experience dictates, Google for "become Agile in 11 seconds" and see what tools one can download and integrate in the personal toolbox! Surprise! There are tools, but they only help you when you are already agile. WTF? It was supposed to be a developer empowering thing!

Actually, this has an only marginal connection to the developer. Agile development is actually a management strategy. No programmer can become agile without the support of their manager. Management in itself is the application of scientific methods to achieve business goals, which are, almost every time, to maximize profits. You see, managers have noticed that they could hardly quantify programmer work. Software development was becoming more artsy and less scientific as technology grew ever faster and more complex.

The typical development cycle of a piece of software is to plan it (sort of) do stuff to it depending on the planning (which always results in changing the original plan or ignoring it altogether), then show it to the customer. They will, almost every time, just applaud and ask you "ok, this is nice (albeit full of bugs), but where is what I wanted?". The manager then gets scolded for not doing their job. But how could one possibly know what the client dreamed of when they said something completely different at the start?

So, what does a manager do when they have a big problem they can't get their hands on? They split it in smaller problems! Divide et Impera! said the Latin managers of old. So the Agile solution was to copy the development process in its entirety, make it as small as possible, then repeat it until it reaches the original size. It's like when you kill the monster at the boss level and he splits in many small bosses (let's call them middle managers) that you have to kill individually to continue the game. Hopefully I have explained this in a way most code monkeys would understand :).

What about empowering the developer? It was a really nice side effect, one that was taken into consideration at the beginning, of course, but I am sure exceeded the expectations of the designers of the process. You see, at the end of each iteration the application should work, somehow, and also be tested, documented, code reviewed and client approved. The client will undoubtedly notice a discrepancy between what he wanted and what was produced, but he can give feedback a lot sooner than at the end of the project. The developer doesn't have to work their ass off to finish the product, sometimes ignoring the most basic testing or documenting techniques in favour of speed, and then be forced to start work almost from scratch because the client either changed his mind or was not understood properly. Therefore there is an increase in motivation and thus productivity and a decrease in unnecessary work. This is also incorporated in one the agile principles YAGNI, which is actually a really buzzy and ugly acronym for "you aren't gonna need it" - in other words, do the least work to achieve the exact desired result.

But most importantly, this is a managerial process, one that is now easy to analyse and even quantify (since the idea to do as much automated testing as possible). If the bugs are too numerous, then testing must be improved. If code is too obscure, code review and refactoring must be done. If nobody knows how to use the product, documentation is needed. But only for the last small bit that was done. Even more cool, the documentation, code review and even refactoring can be done on the code from the previous iteration, while coders are working on the current one!

So, to summarize: to be agile means that your management has decided on a new strategy and you understand the principles enough to get the tools that would make it easier to work under them as well as design your applications to neatly mold to the concept. It does NOT mean you get some library or development tool and it does things for you. There is not an agilizer application (yet? :) take a look at Pex) and the different software patterns like MVC or MVP are used to facilitate the technical solution found to solve the managerial problem of quantifying results (in this case quality) which is Unit Testing.

It's not that Agile Development is not a good idea. Managers don't really see eye to eye with programmers because they have completely different goals - managers see things from the business perspective while developers see it from the beauty and functionality of code. It's like physicists and mathematicians all over again - but both are (or should be) scientific types that try to solve problems in the best possible way. Agile is a happy intersection of their goals, but as it happens, must be implemented in both worlds simultaneously.

and has 0 comments
You thought the World Sucks series had ended? No, it is just in the process of gathering data for cool new posts! This one is about moronic shows on children TV! Do their parents know what "children-centric" stuff their kids watch?

First of all I must explain what "manele" is. It is a kind of music with Arabic and Romanian folk music influences that has become a symbol of a type of Romanian urban subculture inspired from tribalism. You know the type, they are never original: members call themselves a family, they call each other brother, they dress and behave in a "manly" fashion, with speech inflexions that are supposed to show how tough and superior they are. It's like the US "African-American" street culture and in many ways it is a local clone of it.

Ok, now for the actual topic of this post. Yesterday I was watching TV (why, you ask? because I haven't bought yet the second computer and my wife commandeered the only one) and I was given the ultimate proof that it makes people dumb. It was a children TV show that involved teenagers from our own time having superpowers in some mystical realm.

So far so good, but then I noticed how their super powers came from a cell phone! To invoke the magical mana they actually typed some number on the phone pad. Then they transformed into colored knights that were heavily inspired from Japanese shows of the same persuasion, basically a guy in a colourful spandex suit and a motorcycle helmet with a silly sword in hand. The colors of the knights were a bright green, a bright cyan, pink, bright magenta, red and yellow! But what shocked me the most was that they spoke in "manele" style, calling each other "brother" and basically street talk! When they actually combined into a big mechanical knight on a big mechanical flying dragon and fought against what looked like a monster hydra with special effects from the old Japanese Godzilla versus [enter stupid monster name here] movies I was laughing my ass off.

No, really, I am not kidding! This was on TV, on a children's channel! Yeah, bro, that's coo'! Gimme five (gay porn looking knights that "couple" with each other to form a really stupid looking toy like fighting machine)! TV sucks, that was obvious, but to actually show this kind of scatological aberration is even beyond my pessimistic expectations.

Sometimes you need an information like the time taken for a web page to actually reach the client. It is different from the time it takes to create the rendered content as it includes some web server overhead and the actual network transfer. IIS doesn't know anything about your code, so you can't tell it to log everything you need. How do you synchronize the information in the IIS log with the one in your own logging system?

Use the Response.AppendToLog method that will add a custom string to the end of the IIS logged cs-uri-query field. That doesn't help you much, but since you can add any string you want, you can add a key that would help synchronize the two informations.

Quick example:
string key=Guid.NewGuid().ToString();
Response.AppendToLog(" key=["+key+"]");
MyLogger.Write(myInformation,key);


Now you will only have to Regex the cs-uri-query field to find the key, then search the corresponding line in your own log. Simple! Sort of...

We were working on a project for a company that suddenly started complaining of slow ASP.Net pages. I optimised what I could, but it seemed to me that it ran pretty fast. Then I find out that some of the customers use a slow Internet connection. The only way to test this was to simulate a slow connection.

But how can one do that on IIS 5.1, the Windows XP web server? After a while of searching I realised that it was the wrong question. I don't need this for other projects and if I did I certainly wouldn't want to slow the entire web server to check it out. Because yes, changing the metadata of the server can, supposedly, change the maximum speed the pages are delivered. But it was simply too much hassle and it wasn't a reusable solution.

My way was to create a Filter for the Response of all pages. Response.Filter is supposed to be a Stream that receives as parameter the previous Response.Filter (which at the very start is Response.OutputStream) and does something to the output of the page. So I've created a BandwidthThrottleFilter object and added it in the MasterPage Page_Load:
Response.Filter=new BandwidthThrottleFilter(Response.Fitler,10000);
. It worked.

Now for the code. Follow these steps:
  1. Create a BandwidthThrottleFilter class that inherits from the abstract class Stream
  2. Add a constructor that receives as parameters a Stream and an integer
  3. Add fields that will get instantiated from these two parameters
  4. Implement all abstract methods of the Stream object and use the same methods from the Stream field
  5. Change the Write method to also call a Delay method that receives as parameter the count parameter of the Write method


That's it. You need only create the Delay method which will do a Thread.Sleep for the duration of time it normally should take to transfer that amount of bytes. Of course, that assumes that the normal speed of transfer is negligeable.

Click to see the whole class code