Hacker News new | ask | show | jobs
by viewer5 2259 days ago
I'm writing a script right now. So far I've got a constructor written, and comments written for what the "main method" equivalent part of it will be doing.

My next step is to implement the first comment: reading in my input file, at which point I'll add some temporary code to loop through and print out what got read in, so I know I did that right.

Then I'll move on to implementing the next main-method comment, which'll loop through records from my input file, open files it says to, find certain lines, and edit the text of em. So basically using the loop I already wrote above, I'll add in code for it to find the line number I want, and print that out so I know that bit works.

etc etc. It's all iterative. You start with bare bones, and add meat and tendons here and there, iteratively, throwing in test output as you go so you know the bit you just made works.

edit: and you don't have to go in order, either. Writing comments like I did that lay out what my "main method" will be doing, lets me know "okay, i've got a file-reading bit, a file-seeking, -interpreting, and -writing bit, I'll need a bit that outputs results as CSV..." and I wrote above about implementing the first step and a little of the second, but the constructor I have written is for the last step, my results-as-CSV step, because that's a thing that was easy to think about while I pondered the tougher bits. I'll add more to that constructor, probably, as I realize "oh yeah I wanna know about X aspect of each operation result, too!"

There'll be lots of TODO comments here and there as I bounce around, and it'll get built up in bits and pieces, like starting with a spooky skeleton and adding more and more meat to it til eventually you have the whole body