Wednesday 30 March 2011

theStart and Normandie

A while ago I was reporting the release of theStart's latest album, Ciao Baby, and the disappointing direction of their singing. I've revisited them and noticed that Aimee Echo, Jamie Miller and Chelsea Davis started a new band called Normandie which sounds very much like the old theStart, at least from the songs they've published on their MySpace site. Here is a clip from YouTube as well:

Monday 28 March 2011

Stonewielder, by Ian Cameron Esslemont

book coverI said to myself "I'll just read a few passages of the book, just to relax a little, as I have a lot to do". Yeah right! I've started reading and I didn't stop until it was done. Stonewielder is a classic Malazan Empire book, but also bearing Esslemont's personal touch. There is the catastrophic magic battling immense godly power, while the ordinary soldier (the book focuses on heavies) carries on lead by the tragic commander, there are the weird twists from a perspective to another, the switches from a storyline to another, typical of a Malazan book, but also a bit less epicness and a lot more human failing, more characteristic to Esslemont than to Steven Erikson.

I have to say that I find the title to be a little off. The part of Greymane is quite insignificant until close to the end. A great book, nevertheless, and a nice prelude to The Crippled God, the tenth book (and laaast! :( ) in Steven Erikson's Malazan Book of the Fallen series, that I intend to read as soon as possible.

Passed the 70-516 exam

A shameful affair, this. I barely got 820 of 1000 for the Microsoft TS exam 70-516: Accessing Data with Microsoft .NET Framework 4. I could invoke my birthday and some other circumstances to motivate my low result, but let's face it: I could have done a lot better.

What I can tell you about the exam is that most of the questions regard Entity Framework, but also Linq to SQL, classic ADO.Net, WCF Data Services. There are a few questions regarding security and the Microsoft Sync Framework thrown for good measure, as well. Also, there is a .vce file on the net from 2010-07-29, by Carina, and, even if there is some overlap, those are mostly NOT the questions in the exam, while the .vce from 2011-12-09 by acarum is a fake.

As preparation materials I've used Julie Lerman's excellent book Programming Entity Framework Second Edition, which is a thorough and well written book, but kind of huge! Try to allocate at least a month to read through it. I'd really intended to make a post with MSDN resources for the exam, but I didn't have the time.

Onwards, comrades! The MCPD 70-518 exam awaits!

Haters always lose in the end

Don't you hate haters? Never mind that. This kind of question is similar in logic to the CrashIE site that I've just visited (and of the malignant piece of code there - do not open the site with Internet Explorer). Basically, CrashIE is a hater site for Internet Explorer that crashes said browser or at least makes it enter a heavy CPU load cycle. The "solution", they say, is to use better browsers, and you get a nice selection of Opera and Safari and, just to be politically correct, a FireFox icon at the bottom of the page, in between the two other sites that the guy did.

Haters always lose in the end, and this Stanley Shilov will be no exception. No wonder that on his blog he is discussing using Java and Firefox on Ubuntu systems. His extensive experience with Internet Explorer is the thing that probably made him find the hidden bug that a browser will crash if you put it in an infinite loop.

How much of an asshole can you be in order to make a site that will crash some random's guy browser in order to advertise your stupid spellchecker site? BTW, I am writing this in Google Chrome, making said site useless, since it spell checks automatically in any textarea element. Is that the reason what there is no Google Chrome icon on CrashIE?

Bottom line is that you suck ass, Stanley! When I was happy using IE3.0 you weren't even born. I hate you! ;) And, BTW, this is NOT the kind of site that the CodeProject newsletter should have linked to. I am very disappointed in you, guys!

Thursday 17 March 2011

Self piracy, this is hilarious!

You have to excuse me, I've found this blog that I like, Ars Technica, and I can't seem to stop linking to stories there. This one is just funny: UbiSoft released their newest Assassin Creed game and, in a deluxe version, they included a bunch of extras, including the complete soundtrack for the game. However, when looking closer to the ID3 tags for the songs, it was discovered they were pirated versions, distributed on torrents after being taken from the collector's edition of the game.


There is a "theory" that piracy is enhanced by the fact that it is so easy to use pirated content and so damn annoying using the official, paid, version. So easy, it appears, that UbiSoft people found it more efficient to download the pirated version than to go through inner channels to get the songs. They essentially pirated themselves! If that doesn't make you smile a little, you must not be a geek :)

Wednesday 16 March 2011

"Cannot modify the logical children for this node at this time because a tree walk is in progress." Exception

I was doing some tests with localization in a WPF application and I've found that the way to change dynamically the language for a control (and all of its descendants) is to set the Language property. In my application at least, the propagation of change in the entire subtree took a few seconds. As I found out, the way to refresh the language is to actually remove and readd children to control trees. This is probably why simply changing the Thread culture does not work, what the Language property is for and explains why the error was thrown.

During the Language change on the Window object a validation from one of the custom controls there threw a weird Exception: Cannot modify the logical children for this node at this time because a tree walk is in progress.. What could it mean?

This link on StackOverflow says something vague about a bug in the Silverlight charting toolkit, but I think that is wrong, or at least not the root of the problem. I looked through the Reflectored .Net sources and found that this exception is thrown in AddLogicalChild and RemoveLogicalChild methods in FrameworkElement and FrameworkContentElement when the internal property IsLogicalChildrenIterationInProgress is true. Apparently, this property is set to true whenever am internal class DescendentsWalker<T> is "walking" the visual and/or the logical trees. What is this class?

DescendentsWalker<T> seems to be a class used by the WPF framework to find resources, resolve property values, find ancestors/descendants in the control trees, propagate events, etc, so it is a very important low level class. Either because of a bug or exactly in order to prevent one, an error is thrown if someone is trying to change the structure of the tree while something is walking the tree. That is what the error represents.

Now, the only question is how to solve it. The validation code was trying to change the content property of a control, thus modifying the control tree. As such, I do believe this is a slight bug in the framework, as changing the tree could just wait until the tree walk is over, but still. A simple try/catch solve it locally, but what should I do to prevent such errors in the future for all of my code? I can't pad my code with try/catch blocks.

I've tried using Dispatcher.Invoke for the change, it didn't work. The IsLogicalChildrenIterationInProgress property itself does a this.ReadInternalFlag(System.Windows.InternalFlags.IsLogicalChildrenIterationInProgress); and _flags is obviously a private field of the FrameworkElement or FrameworkContentElement class that is never encapsulated into a public property. So I can't check for it in a simple way. Of course, one can always catch Dispatcher.UnhandledException and just set e.Handled to true if this error occurs (Oops, a minor worldwide tremor caused by developer shudder!), but I don't see another global solution.

Well, at least I've thoroughly examined the problem and its causes and possible solutions, however bad or annoying they may be. If you know of a more elegant solution for it, please share it. As this is the only time I ever got this error, I believe it is something that can be handled locally, but only if one knows how to test for it. So, change the Language of your windows or do other lengthy tree walks in order to protect your application from this bug.

Monday 14 March 2011

70-511 Get!

Well, I wanted to convey something like the scene where Mr. Fancy Pants gets the icecream, but still, I passed the MCTS 70-511 exam: Windows Application Development. The grade is a shameful 982, because of a question regarding a DataGridView and a DataSet with related tables (as well as a microwave oven and non-dairy creamer), but it is still a decent pass.

Even if I knew most of the stuff already, some materials for study were: the awful MCTS Self-Paced Training Kit for 70-511 and a post from James J. Foster's blog.

Sunday 13 March 2011

MCTS Self-Paced Training Kit (Exam 70-511)

book coverMCTS Self-Paced Training Kit (Exam 70-511): Windows Application Development with Microsoft .NET Framework 4 is a terrible book. It tries to cover the entire subject of Windows application development, so that means it must explain both Windows Forms and Windows Presentation Foundation concepts. Not only that, but it must do it in a consistent, comprehensible way, avoiding confusion between similar ideas that often overlap. It fails miserably on all counts, probably because it can't be done in a single book, but also because it is a jumbled mess that no one that is unfamiliar with the concepts there can actually learn from. I wonder, was poor Matthew Stoecker presented with the questions in the exam and asked to write a book to cover them? Because that would explain a lot. The 70-511 test itself it not much smarter.

The book starts with Chapter 1: Building a User Interface, in which it presents some basic WPF concepts like controls, resources, styles and triggers. If well written, this could have been a good start. It then continues with Chapter 2: Working with Events and Commands, containing stuff about events and commands, obviously, but then animations! So a novice at desktop applications now has to suddenly contend with animation. Maybe it was a slip up, so let's try Chapter 3: Adding and Managing Content, talking about brushes and the visual tree, even transformations, but then it goes into using MediaElement and MediaPlayer to play sounds and video.

Chapter 4: Windows Forms and Windows Forms Controls starts talking about Windows Forms, but in a completely new way and structure than the WPF part. It talks about modifying properties in Visual Studio, it describes the controls, one by one, with properties and all. It's like a completely new book. Chapter 5: Working with User-Defined Controls starts with Windows Forms, then it tries to explain Control Templates in WPF, then jumps back to user controls, this time in WPF.

The book switches to data in Chapter 6: Working with Data Binding, explaining the WPF Binding mechanisms including validation, and in Chapter 7: Configuring Data Binding it talks about various data sources and DataTemplates, also for WPF. Then it moves back to Windows Forms, Chapter 8: Working with Data Grids and Validating User Input, which starts talking about data bound controls in Windows Forms, but then it goes on and on about the DataGridView. It goes on by combining in a single subchapter Windows Forms validation and IDataErrorInfo in WPF.

Before you know it, in this whole confusing bunch of thrown facts, with no structure or plan, you go through Asynchronous Processing (using BackgroundWorker and delegates, but not Tasks!), Globalization and Localization (yeah, that is the important part) and integrating Windows Forms and WPF together, all in Chapter 9: Enhancing Usability. Chapter 10: Advanced Topics manages to mix together security, application settings and Drag and Drop. Chapter 11: Testing and Debugging WPF Applications was, I think, the most decent chapter, but still kind of frankesteined together from different sources, while Chapter 12: Deployment, talked a bit about Windows Installer and ClickOnce.

Conclusion: messed up as a whole, messed up in each small part, it's a fractally messed up book! You even get "chapter summary" points that were not covered in the actual chapter. I couldn't wait for the book to end, but I've managed to read it all. On Monday I am taking a test on this, for the 70-511 exam and I am really not sure how it's going to work out. Luckily for me I knew most of the concepts covered in the book from personal experience so we'll see how it goes.

Saturday 12 March 2011

Design pattern rant

I started writing a long argumentative post about design patterns. But what is the use? They are abstract concepts that get cemented in the development industry by some influential people or some widespread adoption. Then you get to learn them in order to answer stupid job interview questions. In real life you either don't use them or they are abstracted in the programming language or framework you are using.

You dream of getting to work on your own framework so that the entire company would see how awesome you are, but you will only get to write stupid code for web shops and CRMs. And your life gets to its apogee when the architect who does the company framework or some company middle manager/owner tells you how important they are to know for your work. And you blame yourself for being so stupid and vow to spend your entire free time learning, and you read and you go to the water cooler and say "Hey, Bob, did you know the Adapter pattern is so cool?" and Bob looks at you like you are from another planet and goes to fix the latest "Font is too large in the toolbar menu" bug.

Bottom line: it's a chicken and egg thing. They need you to know as much formal programming stuff as possible so you can improve their crappy work and learning environment, while you need to work in a good work and learning environment so you can get better. The result is always an average soup of meh!

Ridiculous self importance - Part 2

Just a month ago, overwhelmed by a number unbelievable claims from companies and lawyers at that time, I wrote the blog entry titled Ridiculous self importance, relaying what I thought of those claims. And yet now I am forced to write another one. See what happens when people don't read my blog? :)

Let's start with the already blogged move by Red-Gate to unilaterally rescind a promise they took to keep Reflector free. Just follow the link to the story for details, but keep in mind the general idea: a software company makes a promise that is completely ignored later on.

Moving on to EA Games. Like any commercial company that reaches a certain critical size, they become assholes. I am talking about the game Dragon Age II, a game that EA Games promised in the forums it would not feature SecuROM, but it does (read article here)! The company also completely fails to notify the game buyers that the feature is there. Another article then tells us the story of a player that bad mouthed the company and got banned from the company forums for 72 hours. But during that time, the Dragon Age II game he bought could not be played, either. That really sounds a bit 1984, doesn't it? The screen device watches what you say and then punishes you. Welcome to the future!

The last article (one can only hope) in the asshole saga is about Twitter. This service that I could never find a use for has grown exponentially because of two factors: the social paradigm and the API that allowed people to make their own software on top of Twitter. Having reached the critical size, Twitter now publicly announced that it doesn't need third party applications anymore. "Thank you, guys, but we will be making the money from now on. Thanks again!". This is one of the reasons why I distrust the cloud idea. I give enough control to Google deciding what is relevant for my queries (and hosting this blog :) ) to give it or other cloud providers the physical ownership of my business.

I believe these stories are related to the recent efforts to regulate the Internet and not only that, but also how you will be permitted to use your own computer or mobile device. Just like weird events before World Wars, they are only the predictors of an era in which the web will be increasingly controlled and will become just another commercial platform for companies. These events that look morally and logically absurd are attempts to shift the regulatory framework in a direction or the other, while we remain blissfully ignorant of the battle over our heads.

Hmm, mentioning 1984 and predicting World Wars... am I becoming paranoid? Well, I hope so, because the alternative is that I am right.

Monday 7 March 2011

MCTS Self-Paced Training Kit (Exam 70-503) - Review


The book (MCTS Self-Paced Training Kit (Exam 70-503): Microsoft® .NET Framework 3.0—Windows Communication Foundation) covers just about everything there was in the .Net 3.0 version of WCF. As I was saying in a previous post, in order to "upgrade" to a 4.0 version you need to read about the router services, service discovery and simplified configuration.

What I liked about the book is that it is a no bullshit, yet comprehensive reference to the tasks for which one would use Windows Communication Foundation. I found it easy to read and comprehend and, most of all, easy to remember.

Wednesday 2 March 2011

My baby almost died

Don't worry, it's ok now, my years old computer that I can't get myself to replace. The experience has been very educational and I want to share it with you. Here is what happened: the computer that I keep always on started making strange clanking sounds; they came from the HDD. I got a little concerned, but I didn't have the time to address the problem right then. The computer seemed to work fine so I continued (btw, don't you do that in the same situation :) ) to work on it. Finally the computer reset itself and it wouldn't boot. Or, better said, it would boot for a second and restart. I checked the hard drive cables, I removed and cleaned the processor cooler, I vacuumed the power source. Nothing worked. I took the IDE drive from an older Duron computer and tried to boot with that one. It didn't work either, but then again, I had no guarantee that the old drive was functional.

I was really upset. I had an exam to take, all my data was lost, I had a full schedule for days and, being the end of the month, not enough cash to buy a computer right away. And I needed bank loan formalities like I needed an anal probe. But, I thought, maybe I can take the hard drive at work and copy the data, or at least part of it. And it worked. In fact, the drive worked so well at work that I began to doubt that the HDD had any problems. What could it be? I did have a feeling that it might be from the processor cooler that I had removed to clean. After years of use, the thermoconducting gel that transferred heat from the CPU to the metal radiator was only a dusty crust. I decided to buy a cooler or at least some gel.

Of course, any computer shop that was near my work did not have coolers for my old Athlon processor, so I bought gel and then (to be sure) also a cooler for a more recent processor type. I went home, saw that the radiator was way too large for the processor so I removed the fan from the new cooler and placed it (using ingeniously twisted wires) on the old radiator, then applied it with new gel on the processor. And the computer began to work with no drives attached to it. However, attaching the drive would make it reset itself again.

The culprit was, I assumed, either the motherboard (oh no!) or the power source. I removed the old power source from the Duron computer and replaced it on the Athlon computer. And it worked! With wires and thermoconducting gel I brought my baby back to life. I was better than MacGyver! However, the new source would make a really high pitch sound when I turned the computer off and a loud fan noise when I turned it on. I had no intention of buying a new power source for an old computer, I just wanted to make it work.

So I went to my office and borrowed three power sources that had been replaced with newer models. Went back home... none of them worked. As computer parts go, the power source is both the most solicited and the less standard item. There are unlimited ways a power source can fail and the effects on the computer are always surprising. All three displayed some (different) sort of partial functionality. I was considering opening them up and making a Frankensteinian source from them. I know nothing of electronics, but how hard can it be (vision: me burned to a crisp by an electrical fire after having my heart stop due to electric shock). However, I did remember that the source in the Athlon computer was not the original source. I had replaced it with a newer model a while ago and I had kept the old one. I rummaged through my stuff and found the old power source. It worked, it had a somewhat loud fan, but not that loud and it didn't make any electrical high pitched noises. Saved!

I was congratulating myself on repairing the computer using only the things in my house (all but the new cooler) when I remembered that I had an old 500Gb external drive that wouldn't work unless you applied power from the computer power source to the internal drive in the box. And so I did that (using wires again, because the adapter from the old power port to the new got lost somewhere) and backed up all the data from the drive that I thought died. Now I have a backup!

And if I am here, why not borrow a voltmeter and try to figure out how to wire up this external drive so I can use it without all the wires sticking out of it? So the story continues, as this is what I intend to do. I am a guy, tinkering is in my DNA, and it is so satisfying. Also, it helps seeing the uncomprehending look on my wife's face and the horror in her eyes when she sees more wires. It's fun! :)