If this happens more than once on the way down (“some errors should email us admins if we’re not already involved in this transaction”), it gets even worse: build original array, reify to string, {parse, modify, reify} × 2. Whereas just handing the array down through looks more like build, modify × 3, reify and send.
Letting the lowest layer put the data on the wire in the format the wire requires can also be more robust: if there are only Bcc recipients and the To address is “Undisclosed-recipients: ;” then checking whether To is empty loses its simplicity: it can have a non-empty value and yet not have real recipients. Also, nobody at the higher layers has to care whether your addresses are actually separated by comma or by semicolon.
Finally, this lets you push down basic cleaning like calling
array_unique()
into the lowest level, meaning each modification along the way can quickly append and trust the result will be safe on the wire. All those layers become more concise and readable.
No comments:
Post a Comment