DEV Community

Discussion on: Don't return associative arrays!

Collapse
 
aleksikauppila profile image
Aleksi Kauppila

IRL i would probably design a FileSender with only the send()-method. If we just look at the send()-method. It's a void method that throws SenderException. However sendFiles() is supposed to send multiple files.

Regarding design we have two alternatives.

  1. stop execution on first failure and get information about the one file that couldn't be sent.

  2. continue execution and return SenderReport with information about every failed file.

Overall i agree that void is a perfectly fine "return type" and it should inform clients about failures with exceptions. No true/false for success/failure. Command Query separation works.