woensdag 28 september 2011

Developer Jokes

As I did in the previous 2 months where I posted a posted funny programming quotes and funny developer pictures, I’ll be closing this month of with some jokes about our profession. :-)


Why do programmers always mix up Halloween and Christmas?
Because Oct 31 equals Dec 25.


How many programers dose it take to change a light bulb?
None – It’s a hardware problem


A man is smoking a cigarette and blowing smoke rings into the air.  His girlfriend becomes irritated with the smoke and says, “Can’t you see the warning on the cigarette pack?  Smoking is hazardous to your health!”

To which the man replies, “I am a programmer.  We don’t worry about warnings; we only worry about errors.”


Why computers are like men:
  • In order to get their attention, you have to turn them on.
  • They have a lot of data, but are still clueless.
  • They are supposed to help you solve problems, but half the time they are the problem.
  • As soon as you commit to one, you realize that if you had waited a little longer, you could have had a better model.

Why computers are like women:
  • No one but the Creator understands their internal logic.
  • The native language they use to communicate with other computers is incomprehensible to everyone else.
  • Even your smallest mistakes are stored in long-term memory for later retrieval.
  • As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it.


A project manager, a computer programmer and a computer operator are driving down the road when the car they are in gets a flat tire. The three men try to solve the problem.

The project manager said: "Let's catch a cab and in ten minutes we'll reach our destination."

The computer programmer said: "We have here the driver's guide. I can easily replace the flat tire and continue our drive."

The computer operator said: "First of all, let's turn off the engine and turn it on again. Maybe it will fix the problem."

Suddenly a Microsoft software engineer passed by and said: "try to close all windows, get off the car, and then get in and try again."


Life Before the Computer

An application was for employment
A program was a TV show
A cursor used profanity
A keyboard was a piano!

Memory was something that you lost with age
A CD was a bank account
And if you had a 3 ? inch floppy
You hoped nobody found out!

Compress was something you did to garbage
Not something you did to a file
And if you unzipped anything in public
You'd be in jail for awhile!

Log on was adding wood to a fire
Hard drive was a long trip on the road
A mouse pad was where a mouse lived
And a backup happened to your commode!

Cut - you did with a pocket knife
Paste you did with glue
A web was a spider's home
And a virus was the flu!

I guess I'll stick to my pad and paper
And the memory in my head
I hear nobody's been killed in a computer crash
But when it happens they wish they were dead!


Drug Dealers and Software Engineers - A Comparison
Drug Dealers
 Software Engineers
"The first one is free" 
"Download a free trial version"
Have important South-Asia connections (to help move the stuff)
Have important South-Asia connections (to help debug the code)
Strange jargon: "Stick", "Rock", "Dime bag", "E"
Strange jargon: "TCP/IP", "XML", "Java", "SQL"
Realize that there's a ton of cash in the 14- to 25-year-old market
Realize that there's a ton of cash in the 14- to 25-year-old market
Job is assisted by industry's producing newer, more potent mixes
Job is assisted by industry's producing newer, faster machines
Often seen in the company of pimps and hustlers
Often seen in the company of marketing people and venture capitalists
Their products cause unhealthy addictions.
DOOM. Quake. SimCity. Duke Nukem 3D.; Enough said.
Do your job well and you can sleep with sexy movie stars who depend on you
Damn! Damn! DAMN!


How many software testers does it take to change a light bulb?
None. "We just recognized darkness, fixing it is someone else's problem."


God is real, unless declared integer.


A SQL query walks into a bar. He approaches two tables and says, "Mind if I join you?


A man flying in a hot air balloon suddenly realizes he’s lost. He reduces height and spots a man down below. He lowers the balloon further and shouts to get directions, "Excuse me, can you tell me where I am?"

The man below says: "Yes. You're in a hot air balloon, hovering 30 feet above this field."

"You must work in Information Technology," says the balloonist.

"I do" replies the man. "How did you know?"

"Well," says the balloonist, "everything you have told me is technically correct, but It's of no use to anyone."

The man below replies, "You must work in management."

"I do," replies the balloonist, "But how'd you know?"

"Well", says the man, "you don’t know where you are, or where you’re going, you expect me to be able to help. You’re in the same position you were before we met, but now it’s my fault."


A young Programmer and his Project Manager board a train headed through the mountains on its way to Wichita. They can find no place to sit except for two seats right across the aisle from a young woman and her grandmother. After a while, it is obvious that the young woman and the young programmer are interested in each other, because they are giving each other looks. Soon the train passes into a tunnel and it is pitch black. There is a sound of a kiss followed by the sound of a slap.

When the train emerges from the tunnel, the four sit there without saying a word. The grandmother is thinking to herself, “It was very brash for that young man to kiss my granddaughter, but I’m glad she slapped him.”

The Project manager is sitting there thinking, “I didn’t know the young tech was brave enough to kiss the girl, but I sure wish she hadn’t missed him when she slapped me!”

The young woman was sitting and thinking, “I’m glad the guy kissed me, but I wish my grandmother had not slapped him!”

The young programmer sat there with a satisfied smile on his face. He thought to himself, “Life is good. How often does a guy have the chance to kiss a beautiful girl and slap his Project manager all at the same time!”

dinsdag 20 september 2011

No Silverlight for your Metro browser

I’ve just read that IE10 metro won’t support the Silverlight plugin anymore (1,2).  The reasons behind this decision are that they want to make the browser less resource extensive.  Microsoft appears to be aiming for an entire HTML5 supporting browser.  They say that the plugins drain too much battery life with their updates and that they’re not always that secure.

IE10 will come in two flavors with one core, so you’re not completely lost.  The desktop version of IE10 will support plugins.

I think it’s a bit of a mistake that Microsoft won’t allow plugins in the metro version.  It would provide them with the edge they need over other vendors that don’t support Flash and Silverlight.  Though it seems that together with Windows 8, they’re looking to make the whole metro experience as smooth as possible and are eliminating as many risks as possible.

Switching from Metro mode to desktop mode appears to be very easy , if we believe the Building Windows8 blog:
On Windows 8, consumer sites and “line of business” applications that require legacy ActiveX controls will continue to run in the desktop browser, and people can tap “Use Desktop View” in Metro style IE for these sites. For what these sites do, the power of HTML5 makes more sense, especially in Windows 8 apps.
It appears Microsoft is really discouraging developers from using plugins in their website. With allot of big players jumping on the HTML5 bandwagon the clock seems to be ticking for browser plugins…

Another Code Retreat and some TDD as you meant it

Saturday I had the honor of attending another code retreat hosted by Agile Minds at Qframe.  This code retreat was a bit special to me as we were only with 6 men.  Though it was a small code retreat, it was the best one I’ve attended so far!  

We did a total of 5 sessions so no luck breaking the world record ;-) Every session was pretty intense.
The main thing that I’ve learned from this code retreat is that TDD as you meant it can be allot more useful than I initially thought.  Let me first in layman’s terms explain to you what it is.

The most important thing in TDD as you meant it, actually in TDD in general is to have NO design plans up front.  Your mind must be clear of any predefined design choices!  The main focus is to let your test drive you design.  

Then what is the difference with just normal TDD?  Well in TDD as you meant it you actually have no choice then to let the design flow out of your tests.  This is because you write the actual implementation code inside your test.  Here is a small example in function of Conway’s Game of Life:

1. The first step is to write one failing test:

public void ALivingCellCanDie()
    object cell = new object();

    // implementation code comes here


As you can see in this method we don’t assume anything.  We didn’t assume that the cell would be a Boolean, there is not Game object, no Grid object, no Cell object, no design what so ever.  We are just testing the fact that the notion of a cell can die.

2. Make the test pass by writing the implementation code in the test:

So our test is red, now we can implement it.  The implementation would become:

public void ALivingCellCanDie()
    object cell = new object();

    cell = null;


That just looks like rubbish don’t it?  Well yeah… but keep in mind we have nothing at this point, and the first 2, 3 to 4 tests will look silly but then the patterns start emerging :-)

3. Create a new implementation function by:
               1. Doing an extract method on the implementation code
               2. Move the implementation code into an existing implementation method

Since we don’t have an existing method we’ll extract a new one:

public void ALivingCellCanDie()
    object cell = new object();

    cell = Die();


private object Die()
    return null;

4. Only create new methods in the test class

This is important because you’re not sure up front where these methods belong.  You might think that the Die method could belong to some kind of assassin object, but maybe another test will convince you that it doesn’t! 

5. Only create implementation classes to provide a destination for the extracted methods.

After a while when you keep doing this you’ll might notice that some methods belong to each other, at this stage you can start creating an implementation class for them.  But be sure that you have enough proof that shows you that these implementations belong to that object.

6. Populate implementation classes by doing move method from a test class into them

You should only move the methods out of your test class.  There shouldn’t be any need to adapt the methods so they fit inside this object.  When you feel the need for changing the implementation code then you might be doing too much.

7. Refactor as required

At this stage you might have some cleaning up to do, then this is the time to do it.  You have green tests so you’ll always be sure that your code works.

I must admit that at first this is a very bitter pill to swallow. It’s slow and tormenting but in the end you’ll produce very clean, testable and loosely coupled code. Understandably this might be too difficult and slow to use in a production environment and I know that when you’re on a deadline this could prove to be too much overhead.  But I encourage people that have some spare time left to try this out.  It will provide you with a new angle to tackle your problems and you’ll probably end up with a design you never expected.

I’ve enjoyed this code retreat allot and will probably subscribe to more of them.  If you’re interested then register here.  

Big thanks to Erik and Adrian for hosting the code retreat!

Till next time :-)

woensdag 7 september 2011

Is Silverlight the future or the past?

The Silverlight community has been startled since the day Microsoft announced that HTML5 will be an important technology in the desktop environment for Windows 8.  Some of the initial reactions were:
  • we've just been F****D.
  • It's time to flee away from MS, they are just insane.  Looks like Vista "success" was not enough for them
Let’s evaluate.


Some people claim that it is impossible to run the extensive business apps that we have today with HTML5 and JavaScript.  The code would simply be to complex, and the JavaScript technology is too limited.

But is it? There are numerous examples of online JavaScript applications that will blow your mind.  Here are some examples of very complex JavaScript applications:

So if we can build all the above using JavaScript then why wouldn’t we be able to build a ‘simple’ business application using JavaScript?  I welcome HTML and JavaScript to the Windows desktop experience and it is a smart move by Microsoft.

The HTML and JavaScript will probably be combined with the existing .NET technology anyways so why should the average .NET developer worry?  The front end changes but does that mean you will have to throw away all of your code?

Will Microsoft drop WPF and Silverlight?

I find it humorous how many people have asked this question.  The answer is simple: NO.  

They won’t drop WPF and Silverlight… not within the next 5 to 10 years they won’t.   If Microsoft would drop these technologies and stop their support then they would simply be kicking their self’s in the groin (and I have no idea how you would be able to kick yourself in the groin).  

The number of existing Silverlight and WPF are staggering, even though many people think otherwise.  At the moment, statistics show that Silverlight 4 is installed on 71% of all browsers.  Fair enough compared to the 96% of Flash it seems a bit low, but keep in mind that Flash has been around for more than three times as long as Silverlight and has some big players behind them.

Truly cross platform

I once read this article where the author claimed that .NET could possible just be a mistake.  Though I do not agree with all he said, he did have some very valid points.  As the writer in this article mentioned one off the initial selling points of the .NET framework was that it was platform agnostic.  After almost 10 years we can come to the conclusion that this is not truly the case.  It has the potential, but it never reached that point.

So what about Silverlight?  Is Silverlight platform agnostic?  Initially this seems to be the case.  90% of the time you write a Silverlight application, you’ll be able to run it on Windows and Mac.  Linux however is another story.  If you want your Silverlight application to run on Linux with Moonlight then be sure to downgrade a version and even then chances are you’ll bump into problems.

The problem is that a 90% success rate at best for a platform agnostic web application is not enough.  The times you’ll want your application to be platform independent are the times you’ll be making your application available to a wide range of users.  If you, as a company, will be making your application to be publically available then you want to be assured that nothing will go wrong.  It’s your company’s reputation on the line.

At this moment the only true platform agnostic technology is JavaScript and HTML.  It’s proven, sound and has had a long past behind it.  

Silverlight will survive

It seems like the HTML5 news is the only news that the Silverlight community pays attention to. Silverlight is more than just a browser plugin.  It has become the main application platform for Windows Phone 7 and it will likely be the application platform for XBOX .  

If you see it like that then you come to realize that Microsoft might have a bigger future in plan for Silverlight than most developers think.  It might become the unification platform for XBOX, Windows and Windows Phone. 

On the other side: "The future has a way of arriving unannounced." -George Will

We’ll just have to wait and see :-)

dinsdag 6 september 2011

Sharepoint blogs

A couple of friends / semi-colleagues started blogging about SharePoint so if you're interested  check them out!

Michael Van der Borght's Blog 
Timmy Gilissen's Blog 

donderdag 1 september 2011

Linking an entity between web domain services in RIA services

I’m not the biggest fan of RIA services, but I was pretty surprised the other day when I saw how easily RIA handled the sharing and linking of entities trough different domain services.
So suppose we have the following table structure in our database:

As you can see we have 2 tables: Person and Function.  Then we can generate our web domain services by adding an edmx and then adding a domain service class to the solution.

So I told you nothing new at this moment.  
Now imagine evil reincarnated into a person.  We’ll call this person the customer. One day he comes to you and says: “We’ll need to split the Person table to a centralized database for reuse”.  As soon as you realize he is serious your face will probably be going this way:

But have no fear (RIA is here) because it’s actually pretty easy to accomplish this in RIA services!

At first you’ll need to create a new edmx.  The reason why is because the edmx is basically wrapped around one connection string so for each separate connection you’ll need to create a new edmx.

So the 2 databases will look like this:

And the edmx’s will look like this:

Then build the solution.  Before you can build it you’ll have to remove the person operations from the first domain context.  The reason why you have to do this is because your first domain context inherits from LinqToEntitiesDomainService<FirstDatabaseEntities>. The underlying ObjectContext won’t have any reference any more to the Person entityset that you’ve just deleted.

If you have navigation properties defined in the metadata file then you should delete these also to be able to build.

If you are receiving build errors in your Silverlight projects (which will be very likely), then just ignore these.  It is only essential that you’re able to build the web projects.

Then add a new RIA web domain service class generated from the second database and select the tables you want.  

So now you’ll need to tell RIA services that the Function class in the first entity model is linked to the Person class in the second entity model.  To do this you’ll have to create a partial class of the Function entity.  Now add a property there that will return the Person.  The property must be decorated like so:

public partial class Function
    [Association("Person_Function", "PersonId", "ID")]
    public Person Person { get; set; }

The External reference attribute will tell the current domain service that the entity this property is returning is from an external domain context.  

The Association attribute will tell the domain service how to link the entities together.  What this will actually do is generate code on the client side that will filter the appropriate entity out.

When you’re finished doing this, build the solution to trigger the code generation client side.  Then you can open the generated file and see that it generated the following code:

public global::DomainService.Web.Person Person
        if ((this._person == null))
            this._person = new EntityRef<global::DomainService.Web.Person>(this, "Person", this.FilterPerson);
        return this._person.Entity;

private bool FilterPerson(global::DomainService.Web.Person entity)
    return (entity.ID == this.PersonId);

Notice the generation of the filter depending on the parameters we gave to the Association attribute.

If you’re not interested in coupling the entities server side, then you can always manually couple the entities on the client side with a partial class that has the same code as the generated file.  Either way the client side code will be practically the same.

Now we still need to tell our context object where to find the associated Person entity.  We can do this by calling the AddReference method and supply the Person type and the corresponding context in which the Person entity resides.

_context1 = new DomainService1();
_context2 = new DomainService2();


When this is done you just need to retrieve the data from the server and tadaaaa:

var personQuery = _context2.GetPersonQuery();
_context2.Load(personQuery, PersonLoadCompleted, true);

void PersonLoadCompleted(LoadOperation<Person> loadOperation)
    var nrOfEntitiesReturned = loadOperation.AllEntities.Count();

    var functionQuery = _context1.GetFunctionQuery();
    _context1.Load(functionQuery, FunctionLoadCompleted, true);

void FunctionLoadCompleted(LoadOperation<Function> loadOperation)
    var personOfFunction = loadOperation.Entities.First().Person;

Some special notes to pay attention to:
  • Name the relation the same as the entity you are returning
    I find this a very strange implementation but if you name the navigation property different then for some strange reason RIA services won’t generate the relation properly
  • Make sure you don’t have any include attributes above the external reference in you metadata class
    When you do this RIA services will generate an objectset within the service context of that type.  This will generate errors when you’re trying to couple the entity type between the two service contexts.
That’s it, till next time!