Wednesday, 5 December 2007

Bucharest in all its glory

One of my favourites blogs is The BÜKRESH Blog which boasts a number of excellent concise images, although rarely meaningful text. However, I found this particular entry having all the makings of a great article. It has it all: great pictures, ironic text and an unbelievable subject. It is written in Romanian, so I will try to translate it below. First visit the link and see the pictures. (and yes, those are real human bones)

Human bones and empty plastic 2L beer bottles

First a bit of data that might help you understand what is going on: In the old center of Bucharest they recently found ruins from a previous time. I have no idea what time and what the ruins represent as I am not interested in archaeology, but bottom line they tore up a couple of streets and started digging underneath and expanding the site.

Gypsies are an ethnic minority in Romania, genetically linked to populations in India, and mostly shunned for their style of life, unclean living conditions and high criminality rate. They represent a maximum of 5% of the Romanian population and discriminating against them is illegal in Romania.

What the article is about is the way the archaeological site is being handled.

Translation:
Is it hard to describe the mixed feelings the medieval ruins in the Bucharest old center gave me. I passed by there for the first time (across the street from the Comedy Theater on Tonitza street) last week. In the space from the second image
there were 4 people - a 50 years old Gypsy man, sitting in a squatting position and smoking a cigarette, a Gypsy woman of the same age, with all the Gypsy clothing arsenal (I have nothing against them, quite the contrary, but I want this description as clear as possible), digging like she would be working the field, and another Gypsy girl, 15 or 16 years of age, kissing with her boyfriend who came to see her at work. In the top-left corner there was a pile of bones, a complete human skeleton, cranium included, and on the edge of the hole there were bags of food - lunch for the four workers. Yesterday I went there again and this time there was nobody there. I took the pictures you see. Today I passed through again and it was the same situation as yesterday. On the French street there were 10-15 workers digging, aged between 15 and 60 years old, multiple ethnicity and some of them were either drunk or very drunk. They wore no protection gear or uniforms. Some wore Adidas type shoes (and working in mud), no one had gloves or protective helmets. I asked them about the archaeological site and why there were hundreds of years old human bones laying around... They said they didn't know and that people had come before and taken some in big bags. I asked them if their bosses ever came to see them and they said that they do that, once or twice a day...

The firm that is handling the rehabilitation of the old center is called Sedesa and it's from Valencia. The money are sourced in a non-refundable credit (in other words free money) from the Dutch government, a credit from the European Bank for Reconstruction and Development and public funds (the city-hall, Sector 3 division).

I am concluding with these words taken from the Sedesa company site:

Sedesa is a solid business group with more than sixty years of experience and international activity. Its high level of specialisation has not only enabled the group to establish itself in numerous sectors, but also to carry out projects and infrastructure based on quality, respect for the environment and solid technological ability.

by Vlad Nanca on 05 December 2007

Monday, 3 December 2007

Now this is how a man should act...

I am not the one to write essays on how "real men" behave or anything. But this article says it all: http://news.bbc.co.uk/2/hi/europe/7123460.stm. I have all the respect and admiration for Vitangelo Bini, even if he is too old to really lose anything by incarceration. He showed logic and respect for his wife. For her spirit, not her decaying body.

I always thought that if I get into the same situation, I would kill myself. But I wonder if this resolution is not stored in one of the first regions of the brain affected. Before I realise what is going on, I forget I always have this option. In situations like this I say screw the law and the hypocritical society that spawned them. Way to go, dude! This is how real men act.

Wednesday, 28 November 2007

Friday, 23 November 2007

Darwin's Radio, by Greg Bear

I remember reading Greg Bear books a while ago and thinking they were really cool. The coolness, of course, came from his hard sci-fi style, mixing good ideas with believable science. Now, after about a decade I suppose, I've decided to read another of his books and here is my review.
Darwin's Radio cover
Darwin's Radio starts a little like Village of the Damned, but without the extraterrestrial origin, continues a bit like The Stand, without the religious mambo-jumbo, and ends in waiting for Darwin's Children, the next book in the series. The plot is about a major and sudden evolution of the species, without the X-Men powers.

My personal feel was that the writing is less than I wanted. The book seems shallow and uninteresting after reading Peter F. Hamilton. While the science is interesting, it also makes huge leaps of faith and I wouldn't put it behind Bear to end the story with a good versus evil battle. Was I too young to appreciate good writing, starved as I was of anything interesting in my life? Or is this book not so hot?

I will certainly read the next volumes, but I am a bit disappointed. I feel like I am watching a play after seeing a real good movie.

Thursday, 22 November 2007

Nullable types and their boxing in O/R mapping

Nullable types are new to .NET 2.0 and at first glance they seem great. The idea that you can now wrap any type into a generic one that also allows for null values seems valuable enough, especially for database interactions and the dreaded SQL null.

However, having an object that can be both instantiated and null can cause a lot of issues. First of all, boxing! You can define a Nullable<int>, set it to null, then access one of its properties (HasValue). So suddenly a piece of code like obj=null; obj.Property=...; makes sense. But if you want to send it as a parameter for a method, one that receives an object and then does stuff with it, the object must represent the null value, which means it is no longer an instance of anything. Therefore you can't get the type of the variable that was passed to the method!

Quick code snippet:
int? i=null;
DbWrapper.Save("id",i);

With Save defined as:
public void Save(string name,object value)

Now, I want to know what kind of nullable type was sent to the method. I can't see that if the parameter signature is object, so I am creating another signature for the method:
public void Save(string name,Nullable value)

At this time I get an error: static types cannot be used as parameters. And of course I can't, because Nullable is a generic static type that needs the type of the wrapped value. So the type is actually Nullable<int>. My only solution now is to create a signature for every value type: integers, floating point values, booleans, chars and IntPtrs. String and Object are value types, but they accept null, so Nullable<string> is not used on them, but if you count all the other value types , there are 14 of them!

There is another option that I just thought of: a custom object that implicitly converts from a nullable. Then the method would use this object type as a parameter.
I tested it and it works. Here is the code for the object:
Click to show


Update:
There are issues regarding this object, mainly refering to constants. If you pass a constant value like the number 6 a method that expects either Object or NullableWrapper, will choose NullableWrapper. More than that, it will choose a NullableWrapper<byte> since the value is under 256. Adding signatures for int, double, etc causes Ambiguos reference errors. So my only solution so far is to consider the UnderlyingType of even Nullable<byte> as Int32. It is obviously a hack, but I haven't found a good programming solution to it, yet. If you have an idea, please let me know! Thanks.

Links:
Nullable Types (C# Programming Guide)
Check If Type is a Nullable Type - Convert Nullable Type to Underlying Type - C# 2.0 Generics

Friday, 16 November 2007

FxCop integration in Visual Studio 2005 Standard or Professional

FxCop is a free Microsoft utility that analyses compiled .Net code and makes suggestion based on rules, may them be design, security, performance of company policy rules.

The first problem is that you can only use it on compiled code. That means executables and DLLs. But what about ASP.Net 2.0? It doesn't build a DLL anymore, like 1.1 did. How can one use it? I have built an application (one that you will have to message me to send to you) that takes the project name as a parameter and then creates an FxCop project file with the DLLs from the site bin folder as reference DLLs and the DLLs from the Asp.Net temporary folder of that project as analysis targets. That means that you can also use it for ASP.Net now.

The second problem is that FxCop is now part of Team System, the overpriced and overhyped version of Visual Studio, and any attempts to use it with the Standard or Professional versions are cumbersome and undocumented. Siderite to the rescue! Here is a quick way to integrate FxCop as an external tool to Visual Studio and use it for either Console and Windows Forms applications or Asp.NET sites.

Step 1. Download FxCop. The latest version is 1.35, but there is also a 1.36 beta available that knows about lambda expressions and stuff like that.
Step 2. Get from me the FxCopAspNet application (completely free and with source), or build your own. Here is a possibly working link for it: at MediaFire.
Step 3. Open Visual Studio, go to Tools/External Tools and add two FxCop entries:
- FxCop [use C:\Program Files\Microsoft FxCop 1.36\fxcop.exe as Command, "$(TargetPath)" as Arguments and C:\Program Files\Microsoft FxCop 1.36 as Initial Directory]
- FxCopAspNet [use C:\Program Files\FxCopAspNet\FxCopAspNet.exe as Command, "$(ProjectFileName)" as arguments and C:\Program Files\FxCopAspNet as Initial Directory]
Step 4. Just open your web site or application in Visual Studio, compile it, then click on the FxCop item that applies.

Now, this is not meant to be a tutorial on FxCop, here are some links that might enlighten people:
Download FxCop 1.36 Beta
Download FxCop 1.35
Open Source FxCop Integration Add-in for Visual Studio 2005
How to copy the necessary files from Team System to Visual Studio 2005 Professional to make integration work
Use FxCop from your own code
A small tutorial
FxCopUnit, FxCop testing unit project
Video on how to create your own FxCop rules

There are a myriad rules included in the default installation of FxCop, some of them are just annoying, like some naming rules or some telling you you shouldn't raise Exceptions just objects inherited from Exception, but some are pretty good. A lot more can be found on the Internet and now, with the integration in VS Team System, I expect a lot more to pop-up.

Sunday, 11 November 2007

TV Series I have been watching

The third in this category of blog entries, this describes the few TV shows I have been watching lately. The previous entry can be found here.

House MD is a doctors show. A bit more interesting than E.R. and Grey's Anatomy because they actually focused on interesting characters and interesting medicine. However, after three seasons, the quirky intelligent doctor is just annoying, the supporting cast makes no sense and the medicine is becoming a joke. It's never lupus!

Prison Break is the new Lost. It had an interesting premise and I admit I watched it with pleasure for about a season and a half. Then it all went haywire. I predicted it, too... When people recommended the show I said "How the hell can you keep a prison break for 3 seasons?"; and the answer is that you can't. Not without bringing in mysterious government secret agencies with hidden and malevolent agendas. As acting goes, I like Dominic Purcell, interpreting the older brother, but I can't seem to see him in any decent show. You may remember him from John Doe, another clicheatic TV dead end.

Also in the list:
Numb3rs, even if the math has gone sour already and the show has basically turned into another pure police show. (good versus bad silliness)
Stargate Atlantis, which will probably end with this season without any other decent sci fi to replace it.
Battlestar Galactica, which was great, but moving towards boredom.
Regenesis probably won't get another season after season 3. It was never a great show, but it was decent, being Canadian and all :), with a bunch of virus hunters. It could have been a lot more scientific.
Grey's Anatomy is still on the market for my wife, but barely. A doctor show, but now it is very little about medicine and a lot about the human side of the characters; and who the hell wants a movie about people, completely overlooking the cool stuff happening near them?
Private Practice is an off shoot of Grey's Anatomy, but we never even started watching it.
Ugly Betty still sucks enormously and the wife still watches it.
Eureka. The second season waits on my harddrive, cobwebs on each file. Maybe if I am really bored...
Desperate Housewives takes the desperation way too far, probably reflecting the feelings of the screenwriters when watching the audience numbers fall.
A new season of Doctor Who will start in December.