Programming Basics

  Home arrow Programming Basics arrow Page 2 - Coding
PROGRAMMING BASICS

Coding
By: lig
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2006-01-17

    Table of Contents:
  • Coding
  • Thinking before Coding
  • Commenting
  • Coding Style
  • Error Reporting
  • Error Handling
  • Security
  • Reinventing the Wheel
  • Advanced
  • Conclusion

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Coding - Thinking before Coding


    (Page 2 of 10 )

    You have a brain--use it before you ever set finger tips to keyboard. By taking the time to make a few decisions and thinking out the design of a script, you can save yourself hours, days, even weeks of time when your "great" idea turns out being not so great. One thing every programmer should have nearby is the simple paper and pencil. Writing code is the easy part; if you do proper planning then your just writing syntax.

    Procedure or Object Oriented

    One of the decisions you should make before you start coding is what methodology your code will follow. Will you code it procedurally with a library of functions, object oriented with classes or a combination of the two? PHP is a language that doesn't dictate one way or the other--which in my opinion is one of its greatest strengths. Each has its strengths and weaknesses, so pick the method that will work best for your script.

    Basic Logic Flow

    Have you ever heard of flowcharting or pseudocode? They are simple non-language specific methods of working through the scripts logic. With your pencil and paper you write/draw out your logic and do simple bench testing to make sure it works. Here is where you should be spending the majority of your time. You can write out your logic from the step by step if/else level up to the script level calling the classes or functions. Take your time--the more problems you find here the fewer problems/bugs there will be to fix later, and a piece of paper is easier to crumple up and redo then rewriting 1000 lines of code.

    Breaking it up

    Now that you have some of your logic figured out, start looking for things/patterns that are done repeatedly or just seem to go together. Maybe these things can be moved into small self contained functions or classes. Breaking up your code into reusable pieces saves you time in typing and debugging. Typing because you don't have to type the same thing over and over again, debugging because once it is bug free for the first call it will be bug free for the last call.

    More Programming Basics Articles
    More By lig

    blog comments powered by Disqus

    PROGRAMMING BASICS ARTICLES

    - Control Flow Constructs
    - More Time Manipulation with PHP
    - Validating and Manipulating Dates with PHP
    - Using the Date Constructor in PHP
    - Calendar Construction with PHP
    - PHP`s Calendar Package
    - Getting Modified Versions and Correct Dates ...
    - Combining Date Functions in PHP
    - Using PHP for Date and Time in Programming
    - More Exception Handling with PHP
    - Exception Handling in PHP
    - Error Logging and Handling Exceptions
    - Configuration Directives for Error and Excep...
    - Error and Exception Handling
    - Python Modules for Games


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap