If youâve ever been stuck next to a rattling, beat-up car with a hubcap missing and smoke billowing out the back, youâve probably made some on-the-spot negative assumptions about the owner. Now, imagine that same car with 27-inch chrome spinner rims and a customized sound system. Youâd probably think that the ownerâs priorities are all out of whack. Of course, itâs easy to shake our heads at such an obvious situation, and not as simple to see that weâve all been this person at some point in our careers.
As software developers, scripters or coders, weâve all had our chrome rim and bass-heavy moments.
These are the times when we couldâve opted for a better mode of transportation, so to speak, but instead we tacked on unnecessary elements to our applications or scripts, choosing the shiny things over the important ones (like bug fixes, or really diving into data validation or error control). Weâre human, and sometimes, we just want to plow through the boring stuffâwith minimal effortâso we can get to the fun stuff. But this kind of behavior becomes a problem when it turns into a habit. It happens.
Thankfully, these four guidelines will help you stay focused on the task at hand without falling prey to all glossy extras.
1. Clearly define the problem
This concept is probably old hat to senior software developers. But it may be new ground to IT pros who script a lot of things, because most software applications are much bigger than ad-hoc scripts. Scripts are historically less formal, and theyâre written to accomplish one thing. Applications tend to have a broader goal and are written with a large code-set from the get go. Scripts can get extremely large, but theyâre usually not planned that way. Often this happens because the scripter runs into a problem, immediately starts banging out some PowerShell code and winds up fixing 10 problems he didnât even realize he had.
To counter this, itâs important to think rather than act when getting started. Iâm not saying to brainstorm the entire project, just write out some rough code and set the conditions, or simply write some comments ahead of time. When youâre ready, replace the comments with real code. Clearly defining the problem ahead of time will save you time in the long run.
2. Solve the problem first
Youâve clearly defined the problem, now go solve it. Solve the core problem before you do anything else. Donât add any new features you think would be useful, and forget the chrome spinners! Youâre here to do a job and to get that job done. Do all the boring stuff first like formal structure, commenting, validation and error control. Bottom line: Your code needs to be rock solid before you continue.
3. Save new feature ideas for later
Even though you wonât be implementing any new features now, you can still keep them on hand for later. Itâs impossible to stop a creative mind from coming up with ideas. Capture these. Donât get so caught up in your mission that you lose those great ideas for future improvement. You never know when that feature you wrote down on the back of a napkin might turn your code into something unexpectedâjust be sure to implement it after youâve solved the core problem.
4. Set a deadline
Even though Iâm a logical, left-brained thinker, I hate deadlines and pressure. I feel like imposing a deadline and applying pressure only makes things worse. Even so, I know that theyâre good for me. I canât count how many times Iâve started writing a script that should have taken me 15 minutes, and two hours later Iâm still putting the finishing touches on it. If you donât have an external deadline, create one for yourself. Set a timer. Internally, youâll feel this pressure, which will prevent you from wasting time on unnecessary fluff.
Following these guidelines and simply having a get-it-done mentality while coding will enable you to write more robust, reliable code with fewer bugs. Even though you might move a little slower, and the process will require more thinking time than coding time, I guarantee your code will have more mileage in the long runâcomplete with chrome spinners and one awesome sound system.