J
Johannes Bauer
Hi group,
I'm looking for a OO idiom and currently just have a knot in my brain.
I'll explain what the result should be and hopefully somebody can help
me out.
Let's assume I have a class A which has a method setValue(int, int).
Let's further assume that the operation is quite expensive (for example,
think of a database commit). However, in order to keep complexity low,
consecutive setValue() operations can be combined. Assume for example that
a.setValue(w, x)
a.setValue(y, z)
would be equivalent to
a.setValue((w ^ y) * z, z - x)
i.e. the expensive setValue() operation would be executed only once at
the cost of cheap arithmetic operations.
The way I would like this to behave is have the setValue() operation
return some kind of cascadable object that does a "commit" when the last
operation has finished. In other words, it should be possible to:
a.setValue(w, x).setValue(y, z)
(and cascade them infinitely) so that the operands are first all fully
evaluated and then there's only one commit action.
How is this possible with the least overhead in times of runtime
complexity? I don't really have any good ideas here. Would be great if
you could help me out.
Best regards,
Joe
--
Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <[email protected]>
I'm looking for a OO idiom and currently just have a knot in my brain.
I'll explain what the result should be and hopefully somebody can help
me out.
Let's assume I have a class A which has a method setValue(int, int).
Let's further assume that the operation is quite expensive (for example,
think of a database commit). However, in order to keep complexity low,
consecutive setValue() operations can be combined. Assume for example that
a.setValue(w, x)
a.setValue(y, z)
would be equivalent to
a.setValue((w ^ y) * z, z - x)
i.e. the expensive setValue() operation would be executed only once at
the cost of cheap arithmetic operations.
The way I would like this to behave is have the setValue() operation
return some kind of cascadable object that does a "commit" when the last
operation has finished. In other words, it should be possible to:
a.setValue(w, x).setValue(y, z)
(and cascade them infinitely) so that the operands are first all fully
evaluated and then there's only one commit action.
How is this possible with the least overhead in times of runtime
complexity? I don't really have any good ideas here. Would be great if
you could help me out.
Best regards,
Joe
--
Ah, der neueste und bis heute genialste Streich unsere großenZumindest nicht öffentlich!
Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <[email protected]>