[ale] Why define one function inside another (bash, awk)?

DJ-Pfulio DJPfulio at jdpfu.com
Thu May 25 13:25:17 EDT 2017


On 05/25/2017 01:08 PM, Joey Kelly wrote:
>> In fact, my initial code is usually a page of comments describing what
>> needs to happen, in order. Then each of those comments usually becomes a
>> function. If a function gets too long, more comments are written and
>> more sub-functions are made, about 5-20 lines at a time.
> 
> A lot of my code is exactly like that... document first, code later.

For non-trivial programs, each comment might be an entire class, if
doing OO.

I actually do it to help remember where I left off the next day or the
following week after being interrupted.  Sleeping helps wipe memories.
This isn't something new caused by age.  When I coded in my 20s, it was
good to have reminders too. ;)

On any complex code that requires multiple sessions to complete, I'll
also use some tagged comments :bug: :todo: :simplify: to help me recall
what I didn't have time to do the first time.  Sometimes the expected
case is really easy to code, but all the odd situations are much harder,
so they aren't handled on the first pass.


More information about the Ale mailing list