If I encountered an API that forced me to pass a handler for no reason other than to force me handle a result, I'd be miffed. The handler is inconvenient to say the least. For example, handlers prevent the simple composition of functions.

I cannot say f(g(x)) if g returns its value through a handler.

Instead I have to do something horrible like this:

interface H {handle(x)};

class H_imp : H {x get(); handle(x) {this.x = x;}};

H h = new H_imp;

g(h, x);

f(h.get);

From: (benc) at 05/24/23 08:44:34 on wss://nos.lol

CC: #[4]

>---------------

>The real life scenario that inspired this quest dealt with life cycle. The value returned was supposed to be used to allow a caller to manage the result.

>

>We found instances where consumers where simply ignoring the result leaving things in a bad state.

>

>The handler forces the consume to provide _something_ to manage the result. I think this fits the Tell Don’t Ask idea.

Reply to this note

Please Login to reply.

Discussion

That’s fair.

I think what is goofy in my situation is that I have an internal api that requires orchestration that a consumer shouldn’t have to do in the first place.

I should encapsulate that behavior and just keep it simple.