Earlier quoted context omitted.
State can be stored in instance variables as well, and should be if many small functions share them, it's what objects are for.
> State can be stored in instance variables as well... but then we are back to the beginning of the thread...
Simple Ways of Reducing the Cognitive Load in Code
201–203 of 203 posts
Re: Simple Ways of Reducing the Cognitive Load in Code
#202Earlier quoted context omitted.
It's more like the pipe operator in ocaml ( http://blog.shaynefletcher.org/2013/12/pipelining-with-opera... ). The lisp version has the extra advantage that you don't have to repeat it between all the intermediate functions. ((->> 2 (* 100) str count) vs 2 |> (* 100) |> str |> count).
I understand how a lisp implementation would work here to require only the single operator (I'm assuming a fairly simple macro). Would it not be possible to do something similar in another functional language to take a and apply it sequentially to a list of function calls?
Re: Simple Ways of Reducing the Cognitive Load in Code
#203Earlier quoted context omitted.
Stream based programming is a paradigm that with some training and proper code indentation is much , much faster to read than a nested for loop. Once you get used to it,you can literally fast-scan code written in this style with the confidence that you are not missing anything. Also, assuming you do not use mutable state, it also has the advantage of being easily parallelizable without any code changes. (As well, as…
"Stream-based code is certainly not something you can read off the cuff." List transactionsIds = transactions.stream() .filter(t -> t.getType() == Transaction.GROCERY) .sorted(comparing(Transaction::getValue).reversed()) .map(Transaction::getId) .collect(toList()); I honestly think most programmers fluent in Java 7 programming, can guess this is finding "grocery" type transactions, sorting by "value" transaction prop…