3 ms·
Thanks for the write-up. I've had to re-read a couple of bits, but that's how you learn :) My switch use to date has almost entirely been about parsing command
by vacri 10y ago
Thanks for the write-up. I've had to re-read a couple of bits, but that's how you learn :)
My switch use to date has almost entirely been about parsing commandline args - one of the two time I didn't do that was when my colleague talked about the code smell.
It's been interesting watching how new areas in programming just unfold potential in front of you as you learn. My bash scripts used to be relatively simple, serial things, then a mentor forced me to start using functions - and that was eye-opening. Things made more sense, and not least because I had to keep less 'state' in my head. You mention map and similar, and this is something I haven't really touched yet, but it sounds like it'll help some of the things I do (mostly ops scripts).
Thanks again for the write-up.
- optionalparens 10y agoIt sounds to me like you also need to start focusing on atomic functions and abstractions more in general. Your functions should do one things as I mentioned. Regarding "map," "reduce" is probably the one you want to learn first because you can express many functional constructs like "map" in terms of "reduce." As a general word, parsing command lines almost always tends to be ugly. My general advice here would be to use the built-in stuff or at least a well-used library as much as possible. If you are finding that you are doing a lot of work yourself or using reg-exs that you made, that's often a side that you are doing something wrong. Anyway, lots more but I don't want to overwhelm. Good luck!