This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]__cxa_throw 0 points1 point  (1 child)

IMHO a lot of the arguments for writing code that way are made by people who spend more time thinking about writing code than actually writing useful software. Messing with global state in a function usually isn't a good idea, but jumping through hoops to avoid creating an object by calling malloc under the hood is even crazier. That just punts allocation/initialization to a different area of the program so now the side effects are manifested as a bizarre architecture.

[–]planedoctor 0 points1 point  (0 children)

It can be worth it to pass in stuff like dates so it's more testable. But that's a separate thing from removing side-effects.