4 tips to help programmers stay on track
- select the contributor at the end of the page -
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.