3 ms·
I am a script junkie. I have to, just have to script every task out. Here's what I've realized. First do it manually, then automate it. Doing manual tasks is
by sh87 8y ago
I am a script junkie. I have to, just have to script every task out. Here's what I've realized.
First do it manually, then automate it.
Doing manual tasks is frustrating enough to motivate me to automate it. Plus I have a much better understanding of the inputs, the required outputs and constraints for the script to be more useful.
Let your scripts evolve.
Don't force everything in the first go. Simplicity is the key. Let them be rigid, readable and in a single file at first. Then, introduce flexibility as required. Abstract out core functions into individual scripts/functions/modules. This builds a certain sense of familiarity with the code that is just too endearing and eventually very productive.
Reuse your mini-scripts.
Each of my scripts does one thing. There are super-scripts that combine many of those for a task that I am performing at the moment. DRY principle. The more simple, atomic and mutually agreeable your scripts are the more powerful they get. This is just the unix way of doing things. Nothing new.
Write consistent code comments
You will write. You will forget. Make the code comments personal and consistent enough for you to immediately recognize them.
Use version control
Absolutely use it. There will be many versions of your core scripts/functions that dont agree with each other. My personal preference is a version number (semver) suffix on each file to identify which core script is used by which task script.
Reap the rewards
The rewards of putting in the effort to me have been akin to compound interest on an early investment. I have reused core scripts so heavily that prototyping any new idea is pretty easy. If there is something that a script does not do, I know what I need to read over the next weekend :)