Tuesday, January 30, 2007

troubles with XmlDocument

I love it when things don't quite work the way you think... especially when the thing that doesn't work is just totally weird...

We were writing tests today for a class that uses XmlDocuments. To test the xml loaded/saved, we used memorysteams and byte arrays to control what was loaded and validate what was saved.

Seemed simple enough and our xml was even simpler:
string someXml = "<myxmlnode someattribute="value"/>"

The following code saved the xml into a memory stream:
XmlDocument document = new XmlDocument();
MemoryStream stream = new MemoryStream();

A bit later this stream was loaded by our class under test
XmlDocument anotherDocument = new XmlDocument();
anotherDocument.Load(stream); <----- THIS THROWS AN EXCEPTION!!!!

We read the bytes of the stream and decoded it to reveal this text:
"<myxmlnode someattribute="value" />"

Do you see? The difference is subtle, but enough to cause a problem. It seems the xml document added a space between the quote and the closing tag and this made it impossible to load the steam.

It took us some time to narrow down this as the cause of the error and we didn't spent too much try trying to figure it out, so we just changed the xml to this:
"<myxmlnode someattribute="value"></myxmlnode>"

Problem solved... well not really, but it loaded and fixed the test -- I would assume there is a flag or something to change this behavior, but I would have thought the default behavior of save/load would work together

Sunday, January 28, 2007

Speaker For the Dead

Just finished the second book in the Ender series. Quite interesting, but a bit predictable -- though its the thought of the characters that makes these books so good. I liked Ender's Game even more, but I found this book fast moving and didn't want to put it down. It was emotional, interesting and I definitely recommend giving it a read.

Thursday, January 25, 2007

forever haunted

i never spoke to you enough, my memories aren't there.
i watched you suffer
and then you dissapearred
and its always in my head.
sometimes i remember you before, but it doesnt last.
those memories aren't deep. they are silent. they are unassuming.

Is this the default behavior?

Maybe we're doing something wrong...

We have a WPF Window (very exciting, no?) and if we override the OnKeyDown method, if any child has focus, it will not get key events -- it doesn't seem to matter if the event is handled or what child has focus. This is most annoying when the child that has focus is a TextBox of some kind.

To temporarily get around this problem, we added this code:
if (FocusManager.GetFocusedElement(this) is TextBoxBase)

Seems a little overkill to need to do this... i feel like I'm taking crazy pills!

A visit with John Maeda

Today John Maeda came to the office to talk about simplicity and give feedback about Ript. It was interesting and I enjoyed talking to him more than reading his book (which was 100 pages of falling asleep on the train).

Overall, I'm not into his "laws" of simplicity -- I guess its the scientist in me... the use of the word laws for ideas... especially abstract ideas. However, he did have interesting ideas for Ript and I found the parts of the discussion that were not focused on simplicity quite entertaining.

Days like these really make me appreciate working at Oxygen. So do days like yesterday, when I won an iPod :)

Wednesday, January 24, 2007

Lazy with untested code...

I'm a little backwards... I think most people who get into testing are paranoid about untested code, so they are more careful when they are in the realm of code untested. I on the other hand am so use to testing and so confident in the coverage that I almost never run an application after I make a simple change, just run the tests and go... So, when I happen to refactor something, like change a base class that had an inheriting class that wasn't under test, I've caused crashes and other bugs. Before testing, I was so disciplined in fine tuning my code -- no bugs, no problems -- perfect code (well close to it). Its kinda weird that with testing, my untested code has become so poor....

Testing makes writing the code more difficult cause well, personally I find testing to be a completely different way of thinking, but it makes life after the test is written so much easier. I don't have to worry about a refactor breaking something cause its all tested!

Anyway, the point is this:
1. I should be less lazy when I change things that aren't tested
2. Everything should be tested!
3. If I find something that falls under (1) I should enforce (2)

Anyone else have this problem? Has anyone found that pairing and testing made them a more lazy/less disciplined developer when they code alone and/or without testing?

Tuesday, January 23, 2007


Its my first day, so I've got lots to say... I joined GamerChix this week -- its for xbox live girls and women. Its really exciting cause I'm always playing with guys; I actually have yet to play with any females, so hopefully I'm make some new friends and play GOW with some women!

BTW -- I totally suck at Gears of War when playing against actual people. The single player game is really fun and I do much better, but for some reason I have so much fun getting killed over and over again. Every once in a while I have a really good streak and do some nice killing, but mostly I die and laugh, its all good fun though.

If you didn't guess already, my tag is Wunda -- send me a friend request and we'll play!

I'm gonna kill Vista!!!!

So Vista (which by the way I can't seem to remember is not pronounced a la terminator style -- hasta la vista), is most annoying to develop for... At least thus far... It seems that you have more problems the higher security you run in -- so if your application needs admin privileges you are totally screwed!

Those of you who lost your ability to accept drops when running your applications in Vista, you should check out this article.

Also, if you are developing on Vista and you have assemblies that are registered with COM, you need to run VS in admin mode, but beware, if you do this it seems to also debug your applications in admin mode, which causes other problems... So maybe build with one version of vs and debug with another? We haven't found a good system yet and we are trying to get drag/drop to work with a Browser plugin we have, which works sometimes and doesn't other times... I think I'm starting to go off on a tangent in my brain... is it time to go home yet?

Is Vista driving anyone else nuts? I mean, the dialogs alone are really getting to me... I'm not even reading them. Looks pretty though.

Welcome to my Blog

Hi Everyone! Welcome to my Blog!!

As part of my personal goals for 2006 I am becoming more involved with the software development community. I am also participating in a triathlon, so I'm going to be posting info about my training and fund raising campaign.

Thanks for visiting and happy reading!