Cookbook: PureTransformerA number of components have a common format - specifically they take every piece of data they receive, transform it somehow, and pass the data on. Take for example this exampe from the HTTPClient page:
In the example above, the important part of the example is highlighted red the common parts of the components are highlight in green. Clearly this amount of boiler plate code actually hides what's actually going on here. As a result the PureTransformer component exists.
To show how this works, we'll leave the important part of the above example red, but show the shorter version here:
The biggest downside of the PureTransformer is that you sometimes lose the intent behind a component due to the reused name. As a result, creating a prefab is sometimes a nice idea. What's a prefab? It's simply a function !import feedparser
Using a Prefab to show Intent
The nice thing here is we now have the best of both worlds - the code in the pipeline shows the intent, whereas the code performing the transforms now doesn't contain any repetition. The other nice thing about doing things this way is that you gain correct shutdown handling for free at the same time! :-)
This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)
(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved