Skip to content
loading...

re: Don't return associative arrays! VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I get where you're coming from, but this just shifts the coupling from the code to the data. Which is totally fine if you're in a situation where y...
 

Thanks for your comment!

Frankly, i'm not really sure if it's that good design to return these sort of reports. To me that means the service has knowledge that there's is some sort of UI where those values are somewhat important. I left myself a backdoor by giving SenderReport a method to print itself which gives the object some behaviour.

I do however think that it's useful to give data some context by encapsulating it into an object. It allows us to fall back on sane defaults and handle other data related issues in a very limited scope. After all you can't tell data to do anything. With objects you can.

I can't say i have much experience about this, but just a hunch that a system can be more robust when the focus is not on what kind of data is processed but what kind of services objects provide for each other.

code of conduct - report abuse