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:
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! What's next? get this blog rss updates or register for mail updates!
4 comments:
That's the Builder Pattern
Microsoft implemented here only a "preparation" for the Builder pattern - they assume that people will use the XmlWriter methods in order to construct XML documents. In other words Yaron's code is the missing "Director" part. But if one uses the XmlWriter method for other purposes (for example in order to create load conditions by consuming memory with arbitrary calls to the XmlWriter methods) - no builder takes place.
Builder, beyond doubt
You're all right - builder it is
Post a Comment