Re:Please do not attempt to simplify this code
by usrusr on Thursday December 27, 2018 @06:47PM
(#18773691)
Java (like many other languages of that generation) suffers from a lack of idiomatic 1:1 visibility. Whenever you split something up in Java it litters a namespace that is much bigger than necessary. Even private is too big when the class is full of tiny methods most of which most will never be meaningful to any of their peers except for that one call site. Sure, you can create inner function objects and with 8+ it's not even completely weird anymore, but that's still a far cry from the nested functions goodness of Pascal style "structured programming".
Re:Please do not attempt to simplify this code
by TeMPOraL on Thursday December 27, 2018 @07:14PM
(#18773834)
Agreed. I don't remember much from my brief exposure to Pascal years ago, but spending a good chunk of my programming years in Common Lisp has spoiled me; the simple ability to nest functions is something I sorely missed when working on Java codebases.
Re:Please do not attempt to simplify this code
by mrgriffin on Friday December 28, 2018 @08:38AM
(#18776605)
One of my favorite features of Haskell is that I can use where to write the auxiliary function definitions after the code that use them, but keep them scoped inside of a single function.
A relatively bad example here: https://wiki.haskell.org/Worker_wrapper#Hiding_the_worker
Re:Please do not attempt to simplify this code
by yawaramin on Saturday December 29, 2018 @05:55PM
(#18786201)
Bindings in the `where` clause can still access names in the main binding: https://wiki.haskell.org/Let_vs._Where#Advantages_of_where
This runs the risk of strongly coupling them to the main binding and making them less reusable. IMHO strong coupling where two bindings are aware of each others' internals should be avoided.
Re:Please do not attempt to simplify this code
by cannabis_sam on Sunday December 30, 2018 @08:55AM
(#18789171)
Like your link says: doesn’t lambda lifting solve that problem?
That’s what I always do if I want to move an auxillary function to the top-level for reusing elsewhere.
There's a balance to be struck here; you want to minimize the size of the code a developer has to understand to work on (or with) a given abstraction, but you don't want to split beyond that point, as it only makes the developer jump around files. In my experience (with Java in particular), current development trends involve splitting the code too much.