Some while ago, i saw the following code in a project i’m working:
string[] a = (string[])Array.CreateInstance(typeof(string), 10);
And then i became shocked… I called him every name in the book. And why? Because the complication above could be replaced simply by:
string[] a = new string[10];
And there are 2 reasons:
First: The IL generated by the CreateInstance is much more complex than the IL generated by the new operator:
Create Instance IL:
IL_0000: ldtoken [mscorlib]System.String
IL_0005: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_000a: ldc.i4.s 10
IL_000c: call class [mscorlib]System.Array [mscorlib]System.Array::CreateInstance(class [mscorlib]System.Type,
int32)
new operator IL:
IL_0011: castclass string[]
IL_0016: stloc.0
IL_0017: ldc.i4.s 10
IL_0019: newarr [mscorlib]System.String
Second: because the CreateInstance uses reflection and, because of that, the operation is much more slow. Here are the times, in Miliseconds, for 1 million iterations of each operation:
CreateInstance: 406,2422 ms
New: 31,2494 ms
Has you can see, reflection is very expensive. In this case, just the line of code with CreateInstance is 13 times more expensive then the one with the new operator.
So, be careful where and when you use reflection. The bad use of it can result in a performance break of your application.
Step 1: Go to www.google.com
Step 2: Write in the search box: google 1337 and hit “I’m Feeling Lucky” button
Step 3: feel 1337 ![]()
This is one of the most useful things i found in a while. Vector Magic is a online tool that vectorizes an image for you and for free. The main avantage of vectorize an image is that you can resize it all that you want without lose any quality.
There are several proofs of concept that you can watch and see that this tool actually works. Although, this tool is not perfect because, in some cases, the output vector image becomes a little distorced. But the final result it is pretty acceptable.
In conclusion, although there are some gaps, this tool is absolutely fantastic.
Here is the link: http://vectormagic.stanford.edu/
One of my passions is, without doubt, Taekwondo. This weekend i had a demonstration in Portimão, Portugal. I was part of two sketches of self defense. Although it not went 100%, I think my school left a really good impression.
Here is a little video of what happened in Portimão this year:
Just for the record, in 2006 we had an equivalent demonstration in Lisbon with all the schools of my association. Here’s the sketch i presented in the past year:
I was searching the web to see if i could find a presentation of an old college professor named Luís Falcão. I asked Google and “he” told me that he’s blog was here. I was traveling truth his blog when a found this post.
I became curious and I went to the site he pointed in his post to see if the presentation was has good has he was saying.
I think that, like my professor said in his post, this is probably the best presentation i ever seen. It’s simple, goes directly to the point and is presented in a fantastic new way.
The presentation is about something named Identity 2.0. Basically identity 2.0 is the new way to see identity on the web. A way to make identity a standard. And instead of a user have 10 diferent logins in 10 diferent websites, he just have one identity that is shared by all of them.
The speaker is Dick Hardt, founder and CEO of a company named Sxip ( pronounced Skip) that stands for Simple eXtensible Identity Protocol. Dick, congratulations, or presentation is really great.
You can the full video here (it really worths the time spent): http://identity20.com/media/OSCON2005/
Today was the day were i synchronized myself with the recent new products Microsoft has to offer in the Microsoft Conference (PT)
Starting in Visual Studio 2008 new features, passing by Sql Server 2008, Linq, Silverlight and ending with Windows Live Services.
The most interesting presentation of the day was indeed the one about Linq made by an old college teacher, although the subject of the day was Silverlight.
I liked it so much that i REALLY want to do export battles in Orion’s Belt into Silverlight. Battles will be more rich and more eye candy.
Here is a preview of the battles as they are today:

Yesterday Microsoft Visual Studio 2008 and Framework 3.5 shipped for the MSDN subscribers. You can have more detailed information about new features in ScottGu’s blog.
This makes me wonder… Today I still work with framework 1.1 and VS2003 in my work. When will enterprises make the migration for the VS2008? Well, they must first pass by VS2005, right?
I think the migration will be made around year 2015 (give or take)…
This is bad. 2 days (or is that 3?) without writing anything in the blog… First the crazy weekend and then I forgot my laptop, my workstation, in my girlfriend’s house… grrr. Where is my head? don’t know…
Oh well..
This weekend passed in a flash. Saturday was a very important day for me. A day that gave me additional motivation to continue my work in the games development area. And, at night, I went (with Tiago and Pre) to see a talk show named “Gato Fedorento” (something like “Stinky Cat” in English). The show was programmed to start at 10:30 p.m. but only started at 00.30 a.m. Let’s just say that, in that period of time, I basically slept.
Sunday was a very very interesting day also. In the Morning, training Taekwondo for a Demonstration that I’m going to participate at Portimão, 25 this month (next Sunday) around 2 p.m. In the afternoon I went to see American Gangster.
Such a hard weekend made me sleep 11 hours on Sunday… It felt good!!
Parkour (sometimes abbreviated to PK) or l’art du déplacement (the art of displacement) is an activity with the aim of moving from one point to another as efficiently and quickly as possible, using principally the abilities of the human body.
in Wikipedia
Here is a video of 2 Portuguese kids. Is good to see that we have such good traceur in Portugal!

Google has a tool for companies that consists in a server that craws all the information in the company and indexes it.
Today i passed all the afternoon playing (user perspective) with that little powerful thing.
The usage is simple. The machine is configure to have several types of indexes. So, when you request the information, the machine only returns the information about the specific thing you are searching for.
The Request is simple. Is a Http Request to the specified url were you pass, via query string, the information about your search (search key and several configuration parameters).
My implementation was very simple. A class, that i called it GSA (stands for Google Search Appliance
), with a method called Search. This method receives 3 parameters: the string to search, the start item and a filter parameter.
The filter is the more strange parameter here. It is used to return or the most relevant information, or all the results. The start item is the index of the first element that GSA must return( ie. Give me the elements starting at index 10). Finally the string to search… obvious…
When the Search method is called, i make an Http Request to the server, obtain the information (in a XML format), parse the information using Xpath, return the array of results to the class that invoked GSA (in my case a ASP.NET page) and render all the information.
Simple right?
Well, that is not necessarily right. The initial idea of the manager of my project was to copy a code of someone that already implemented a similar thing. Let’s just say that the boy that implemented it didn’t know how to program. Mixed all the fundamentals of programming (divide the application in Layers for instance). The boy inserted all the code in the Load event of the page, in a single method… no comments…
Unfortunately, in Portugal at least, the programming companies only want what we usually call a Code Monkey and, for that reason, the clients spend millions of euros trying to fix something that could be made correctly at first time.