

OO Side Effect Free Programming - jamongkad
http://www.programmersparadox.com/2008/08/27/oo-side-effect-free-programming/

======
ntoshev
I disagree. Obsessiveness with small methods means less opportunity to keep
your transient state in local variables, meaning you are going to make it
object state (use object fields), which would actually _increase_ your side
effects.

Edit: It occurred to me that there is a case when you need to move state out
of the stack to global or instance variables: programming async IO. It is
notoriously inconvenient for exactly this reason.

~~~
LogicHoleFlaw
Method arguments are a decent place to keep transient data as well. Local
variables and object fields are not the only options for scoping your data.

~~~
ntoshev
You are correct, as long as you don't get too many arguments.

~~~
LogicHoleFlaw
Then start using closures :)

------
jstraszheim
Perhaps I've become an FP zealot, but I just can't agree at all with this
author's suggestion. Small methods, "agile", unit testing, and _all that_ are
fine and lovely, but none of them approach the kind of safety and
composability you get from true FP.

------
procrastitron
"It’s the closest to side effect free programming you can get in OO."

No, you can still have side effect free programming in OO. All of the
techniques for programming without using mutable state are language agnostic
and should carry over to whatever OO language you are using. You might have
problems in languages that lack tail-call optimization, but even that can
usually be worked around by using folds.

Now, I'm not claiming that it's feasible to make an entire app in (for
instance) Java purely functional, but you can definitely build the majority of
your app/library/whatever without using mutable state.

