You should probably start by separating your concerns into small, extensible pieces that can be easily stitched together and replaced.
interface Transform {
Widget widget(LookupData lookupData);
}
That by itself is a piece
interface Source {
LookupData lookupData();
}
There's your read side effect.
class WidgetMaker {
Source source;
Transform transform;
Widget widget() {
return transform.widget(source.lookupData());
}
}
There's your composition.
class Cache implements Source {
LookupData cache = null;
Source upstream;
LookupData lookupData() {
if (null == cache) {
cache = upstream.lookupData();
}
return cache;
}
}
Now you can put a mini cache in front of any source
... and so on.