My favourite part of the book "Clean Code" so far is the chapter where he advocates that functions ideally have zero arguments and then advocates that functions ideally do not have side effectspic.twitter.com/ylRTNSbWwy
You can add location information to your Tweets, such as your city or precise location, from the web and via third-party applications. You always have the option to delete your Tweet location history. Learn more
So, what the author means by "functions" is "methods". With a method, there's always one implicit "argument", `this`, the object on which the method is being called. What he's actually asserting is that the ideal method only interacts with `this`
Additionally, he doesn't consider it to be a side-effect when a method call interacts with `this` (sets member variables, for example)
So, for example, instead of one method passing a Boolean flag `isSuite` into an inner method call, he sets `this.isSuite = isSuite` in the first method and then reads from `this.isSuite` in the inner method
As we see here: https://github.com/ludwiggj/CleanCode/blob/master/src/clean/code/chapter03/SetupTeardownIncluder.java#L28-L33 …
Not true. A function can be higher order, making some of its ”arguments” implicit, just like `this` in OO. An object can interact with this without having side-effects, e.g. reading from `this`. This may constitute immutable behaviour such as a logical branch with polymorphism.
A pure function will yield the same output given the same input. A function that takes no argument in this context is a function that takes one argument, usually called unit. So, by definition, a pure function with only one possible argument will yield the same value, ie constant
Reminds me of the Haskell XKCD: https://xkcd.com/1312/
what about random() or time()
They rely on global state; no cheating!
It would certainly cut down on bugs.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.