Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How can a programmer make their codes easier to read/?

Discuss the ways in which a programmer can make codes easier to read

3 Answers

Relevance
  • 9 years ago
    Favorite Answer

    There are several "best practices" books out there. I used some when I was working as a software engineer. There may be new/better ones out there (like from the Head-First series). A good option is to go by ratings on the amazon site.

    If you want my opinion ...here are a few tips

    - code formatting: choose an IDE where you can set good indentation etc. (always follow standards). line spacing helps too. But there needs to be a balance.

    - split your code into logical units : functions, classes, helper functions. it should be a fair tradeoff between one line functions vs 5000 lines of code.

    - follow standard programming paradigms like MVC, OO etc, and use standard libraries where possible(since others who know those models/libs will not have to read any custom code + that code is already tested). Think about dependencies and reuse code wherever possible.

    - document your code : 95% of the time (at least in industry), you will be reading others' code and vice versa. If a huge class/function needs decyphering, it can be painful. something like JavaDocs works great.

    - avoid constructs like "goto". they just make spaghetti code. Also try to maintain a consistent flow of control/data. It makes it easy to read/debug.

    If you want to get some examples of how professional code is written, you can look at some open source code... for example mozilla's code (C++) or something from apache for java.

  • Anonymous
    9 years ago

    Jackson pretty much covered it all but to add to his post, don't forget to comment in your code as well. Although it's good to document the code as well, having in-line comments can really speed up the process of figuring out what everything does whenever another programmer looks at your code without having to go through the documentation. In addition to that, if you ever come back to code you did a while back, it's much easier to refresh your memory by simply looking at the comments you have in the code than it is to look at all of your code without any comments and try to make sense of it. Other than that, Jackson's answer is pretty spot on.

  • Anonymous
    9 years ago

    I make notes against each line of code

Still have questions? Get your answers by asking now.