The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Does this pattern have a name?

There's pattern, basically for converting documents from one format to another: you have one component that turns the source document into an intermediate language, and another component turns the intermediate into the final output language. I've seen the pattern used in several contexts: applications that load or save lots of data formats usually do it, and of course it's pretty much How Compilers Work.

What's bugging me about this pattern is that I've been re-reading the Gang of Four book, and they use it as an example of their "Builder" pattern, which just doesn't fit what the code is actually doing at all.

Does this pattern have a common or canonical name, that I can use to fill in the blank in the sentence "This is not 'Builder', it is '_____'." that I intend to scribble in the margin of my GoF?
mjfgates Send private email
Monday, April 02, 2007
I want to say "Two-step transform" but I'm not finding that at the moment... though this is a pattern I use pretty regularly.
KC Send private email
Monday, April 02, 2007
I'm under the impression that builder patterns refer to how the code is organized, rather than its actual function.

For example, the Wikipedia entry on builder patterns take a hypothetical example of a pizza parlor and show how to organize the code such that you only have to write a little bit of code for each pizza specialty (Hawaiian and Spicy are used as specific examples).

A data converter which is what was described by the OP, can be implemented in a builder pattern. The specific data format in and data format out are the concrete builders, and the raw data itself is the product.

One benefit is that you don't have to write the full set of code for every possible combination of data formats. You only need to write a reader for each format, and a writer for each format you choose to support. In fact, I wouldn't be surprised if Microsoft Office deliberately has lots of readers (all the old file formats) and a couple of writers (the supported new formats) in a builder pattern.
Monday, April 02, 2007
Vineet Reynolds Send private email
Tuesday, April 03, 2007
Andrew Lighten
Tuesday, April 03, 2007
Pipe is good; or 'filter'.
Christopher Wells Send private email
Tuesday, April 03, 2007

His pattern is for producing a view of data but transforming a file in 2 steps is the same general idea.
Mike S Send private email
Tuesday, April 03, 2007
In linguistics it can be called "intermediate language".
Tuesday, April 03, 2007
I like pipe/pipline, on *NIX a lot of the tools use text as the common data format and can be easily chained together by piping one progs stdout to another progs stdin.

It also seems like a consumer/producer pattern.

Honu Send private email
Tuesday, April 03, 2007
When I read the responses, I thought I was wrong. And I may still be wrong. But I'm also starting to think people are confusing form with function. Err... patterns make certain functions easier, but they are not those functions.

I like consumer-producer the best out of the suggestions offered.
Tuesday, April 03, 2007
Tuesday, April 03, 2007
Yes, calling it an Adapter is probably the best fit.  The inner details of it are pretty irrelevant.
KC Send private email
Tuesday, April 03, 2007
Since this pattern follows directly from the 'loose coupling' principle of software engineering, I don't think it should really be called anything in the sense that this is really how *all* format conversions/converters should be designed. However, if I were to put a name to it, I'd call it 'Translator'.
Thursday, April 05, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz