in reply to OO design: returning string and/or special value
The reason I'm here, though, is to ask: how would you design something like this (i.e., the first paragraph), and why?
:)
I'd perform some OOAD
You can't analyze design through the peephole that is your question; its too abstract?
A method that returns a String frog or Squirrel nuts
Sometimes a user may want just the String, but sometimes a user wants the nuts
Its almost as if its a good idea to return some kind of Object thats a string by default, but also an object you can ->chew cause its nuts
Sounds like a different kind of contextual return to me
As a case study on contextual return we can learn from the functional/methodial CGI's param , the classic demonstration that context sensitive return is too much cognitive load for the new and old alike, providing millions of pitfalls, and zero benefits
->non_idempotent_string
->non_idempotent_nuts
->non_idempotent_string_nuts
sub non_dempotent_string { my( $string, undef ) = shift->non_idempotent_string_nuts (@_); return $string; }
I think thats it, more methods .... is it?
|
---|