2 ms·
A technique I use quite a bit is to group functionality within a method using `#{` and `#}` to bound the code doing the thing. It gets you the "grouping" idea o
by war1025 8y ago
A technique I use quite a bit is to group functionality within a method using `#{` and `#}` to bound the code doing the thing. It gets you the "grouping" idea of lots of methods, but if the code is only used in one place, there is no reason to pull it out into a method.
Something like:
#{ Parse input parameters
.... <several lines of code here>
#}
- spockz 8y agoI like this idea and will try to apply it to our code. Why do you prefer it over splitting the code out in a different method? Is it so you can read everything in one glance? If so, an ‘inline’ feature could be added to IDEs to show definitions inline. Also, when using applicative or Monadic style programming there is little reason not to split things of in small separate functions and chain them together in the right order.
- war1025 8y agoYea, it probably doesn't make sense for every coding style. I just find that if I split things apart too much it turns into spaghetti that I have to try to weave my way through to understand what's going on. There are definitely places where it works out really well though.