Monday, March 09, 2009

Who watches the watchmen?

Some say that this movie is just another superhero flick from a book and some say that the film is great. For some people who read the comic novel, they were disappointed because the film missed the essential points of the book. I agree to some of their comments, but I also read the book but I'm satisfied with what the film showed me. I wasn't expecting of something extravagant from this film, the book is really unfilmable, but I really appreciate the work of Zack Snyder through this film. I'll just say here what I did and didn't like about the film.

First, this movie is not a Superman, Thor and Iron Man type of movie, the characters here have no powers, except for Dr. Manhattan who is a nuclear enhanced, buffed smurf (Just kidding..), though Ozymandias caught a bullet (??). They are just humans, armed with karate chops and a body of stone. I think it has an enough exaggeration of the action scenes, Rorschach's wall climbing and characters jumping from a great height, to not make the viewers break away from the thought that the people here are still human.

The film lasts for almost 3 hours, with a slow development of the plot and a dragging poetic narration of Rorschach's journal. Actually my friend didn't know what's going on in the movie for at least 30 minutes of the film. :) But it's a fine approach since the movie's source is a frame by frame material.

Then we go the film's background music. 99 Red Balloons?? The guy behind my seat said "WTF?" after hearing it but I think it's a cool music for the scene. Then again, this guy gave a short sarcastic laugh after hearing the sound of silence (Sorry, I can't help but notice his reactions). Then played the song of Jimi Hendrix' All Along the Watchtower! It's a catchy song when Nite Owl and Rorschach almost hit the ice wall.

I suggest that viewers of this film must concentrate on the film's visual and cinematography rather than compare it to the book. Though, I know it's unavoidable to compare it especially for hardcore comic readers. Well, I respect their opinions. But this movie will really be talked about, since people have mixed opinions and emotions regarding this.

Monday, March 02, 2009

.NET 3.5: LINQ To XML

XML has been a very flexible language to use. It can present or format data in many forms, whether it's a Word file, configuration files, WSDLs and databases. But if you're going to look at it, XML is still very hard to work with. From my experience, when I've been given an XML file, then the requirements or business rule on how I will manipulate it, you'll certainly hear a sigh.

You can manipulate an XML file by using XPath, XQuery and XSLT, but you need to study those stuffs first before you can use them. And also, creating an in-memory XML is very cumbersome. For example, I'm going to create this XML:
Photobucket
I'll show you a common way of creating this XML if I'm going to use the XmlDocument object of the DOM (Document Object Model) by Microsoft. I'll be leaning towards the C# implementation for this because I'm more familiar with it. Here it is:

PhotobucketThis style of coding is a bit long if you're just going to construct a simple XML, and it gives you a few clues about the XML tree structure. Well, the LINQ to XML gives the solution for this problem, and it will support an approach called functional construction. Here's the conversion of the code above using LINQ to XML:

Photobucket
Notice that by indenting the code construct, the XML tree show you the underlying XML. The functional construction gives you a powerful approach when you're creating XML elements, it lets you create the whole XML construct with just one statement.

Another feature that I like to include here is the Language Integrated Query for XML, that's why it's LINQ. LINQ provides you a consistent experience of querying across different data models. I'll be showing a sample query for LINQ to XML:

Photobucket
The object returnXDoc will have the root elemet "student", then have the child nodes "name" and "phone" from the sample XML I showed above.

Query expressions provide an ease-of-use layer on top of the underlying explicit dot notation similar to the way that foreach is an ease-of-use mechanism that consists of a call to GetEnumerator() and a while loop. When working with XML, you will probably find both approaches useful.

There are methods that returns an IEnumerable<object> type, you can manipulate XML (add, update or remove an element/node) and it gives you the in-line queries. Just explore this new API, LINQ to XML is very flexible and it will provide you with a modularized, simple and optimized contruct in developing applications that involves XML.