Showing posts with label design patterns. Show all posts
Showing posts with label design patterns. Show all posts

Friday, February 12, 2010

Quiz #1 - the answer

@YaronNaveh

Quiz #1 is over. Pablo and Dmitry were right, the XmlWriter uses the builder design pattern. A common algorithm traverses over the xml nodes, while a concrete builder (derived from XmlWriter) builds the resulting object (the stream) in a concrete way. This allows multiple builders (xml text writer, xml binary writer) to be used.

@YaronNaveh

What's next? get this blog rss updates or register for mail updates!

Monday, February 8, 2010

Question #1 for the readers: Which design pattern is used here?

@YaronNaveh

There's an interesting design patterns riddle for you readers in the end of this post.

Jesse wrote an interesting post about xml and the .Net framework. He reminds us that xml is actually an abstraction and that Angle brackets are just one (inefficient) way of representing it.

For this reason this code:


...
xmlWriter.WriteStartElement("rawBytes");
xmlWriter.WriteBase64(arr);
xmlWriter.WriteEndElement();
...
xmlWriter.WriteStartElement("blog");
xmlWriter.WriteString("yaron's blog");
xmlWriter.WriteEndElement();
...


can actually generate both "regular" xml and optimized binary one, depending on the implementation of XmlWriter handed to it.

This is actually a great example of a design pattern implemented in the .Net framework BCL.

Can you guess which design pattern is it? Here's the DP list. Give your best shot at the comments bellow!

@YaronNaveh

What's next? get this blog rss updates or register for mail updates!