Guest viewing is limited
  • Welcome to PawProfitForum.com - LARGEST ONLINE COMMUNITY FOR EARNING MONEY

    Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

⍰ ASK What is the best and most efficient way to write code?

If you are working mainly on your own, then I'd suggest some of the following:

  1. Figure out what times in the day you are most alert and most able to focus on coding. Avoid working at other times if you can. In my youth I sometimes would work late into the night, only to discover the next day that what I had coded was gggggggggggggggggggarbage. (Those extra g's are me falling asleep at the keyboard while working :-)
  2. Get in the habit of building unit tests as you go along. The practice of Test Driven Development even advocates building them before you code the routine. Try it. Find a pattern that works best for you.
  3. Use a source control system, if you aren't already doing so. It will allow you to work in small increments, revert changes that are found to cause problems, and compare versions of code. Add good comments for your checkins, taking special note when you are fixing something you just broke on a recent checkin. You may then find it useful to look back over the history log to see if any patterns emerge about your practives that you can take steps to avoid in future.
  4. Use a good IDE to help you write code faster by reducing keystrokes and providing tools that will help you document your code and analyze its qualities.
  5. Adopt a good set of coding standards and embellish them with your own. Like putting your car keys in the same place all the time, you'll spend less time figuring out your own code (as it grows) and debugging your code if you do things in a consistent fashion, like naming variables.
  6. Avoid distractions while coding. Some people can code when listening to music. Others can't, or can't with certain kinds of music. Conversations are even more distracting, so some people shut them out with headphones and music. TV is a distraction. Find a quiet place to code and stay focused while coding.
  7. If possible, have a window you can look out of, preferably with a natural view, and look up from time to time. It'll help reduce eyestrain and help unfurrow your brow.
  8. Read books about good programming practices. These can be specific to the programming language you are using or more general. Learn about what other people have discovered, and then try these things for yourself. Keep what works.
In the end, it's all about what works for you. Everyone is different, and what works well for one programmer might not work well for another. You'll have to experiment.

If you are working as part of a larger team, keep in mind that while your productivity is important, so is the productivity of the overall team. Therefore, it is important that when you adopt practices that improve your own efficiency or productivity, they do not undermine the efficiency or productivity of others.
 
Working alone requires me to know myself as well as my code, I've discovered. I try to code in the early mornings when I'm at my most alert. Coding late at night always seems heroic until I read that nonsense again the following day. Unit testing has helped me avoid numerous self-inflicted catastrophes, and source control is a must for me. I follow coding standards as if they were house rules, and I use an IDE that helps me work more quickly and neatly. Distractions? I murder them. Only instrumental music is helpful. Indeed, there are moments when I simply reset by gazing out the window. For me, it's about discipline, flow, and discovering what works.
 
I have learned the hard way that trying to work through fatigue only results in jumbled code and wasted time—my late-night commits were typically a complete failure. I now try to avoid distractions like the plague and code when I'm focused. I can't even begin to count how many times version control has saved me, particularly when I break something I just "fixed." Because the future version of myself will always value it, I also make myself write tests even when I don't feel like it. Consistent coding practices, a decent IDE, and some silence are very beneficial. I'm still learning and experimenting, but every change makes me work more efficiently rather than more laboriously.
 

It only takes seconds—sign up or log in to comment!

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Back
Top