Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In situations like these, it's a legitimate goal to implement an idempotent, or "functional" core.

So the goal of your functional core is to fully construct the email, and return it to the caller, who then has the choice to send the email, print it, write it to disk, etc.

The program you deploy looks like this

EmailSender().send_email(construct_email(args))

You can test by implementing a "safe" EmailSender interface, so that you're executing the same code that's in prod.

In general, if a job/function is mutating state deep in the syntax tree (i.e. sending emails in the middle of a batch job), I personally see that as a violation of the Single Responsibility Principle.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: