Programmers agree functions that return values are better than having side effects. What's a clear, concise summary as to why side effects are bad? Most arguments I've seen depend on "I'll know it when I see it" or "because composition", but I don't find them compelling
-
Show this thread
-
Replying to @searls
Function signatures are a contract between present you and future you or future coworkers/callers and it is easy for everyone to understand what they’re signing up for. Side effects increase (greatly!) how much state you need to understand to call things safely.
1 reply 0 retweets 28 likes -
Motivating example: User#verify_email! Should the programmer doing an admin dashboard in year 3 call verify_email! optimistically on accounts with an account manager assigned? “Ah that improves our data accuracy and saves the customer a step to unblock on boarding.”
1 reply 0 retweets 5 likes
Surprise! verify_email! also sends an email, because of either a line of code in it or (super likely to have bitten me 1+ times) a Rails object lifecycle hook. Your account managers are now hopping mad because their sophisticated enterprise customers are getting machined emails.
-
This Tweet is unavailable.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.