Programming Basics

  Home arrow Programming Basics arrow Page 3 - 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 - Commenting


    (Page 3 of 10 )

    Why comments? Well it really isn't for you--It's for the guy that comes after you (which may in fact be you in 6 months). Don't comment every line, but do use enough comments so "the guy after you" can follow your thought processes, business logic and coding jokes.

    Block

    Block quotes (using the C style comments /* */) are used mostly with functions, classes or complex logic. Here you can impart lots of information and if you follow the PHPDoc formats, you can also generate HTML documentation for your classes or functions. Here is an example:

    <?php
    /**
     * Register a temporary file or directory.
     *
     * When the destructor is executed, all registered 
     * temporary files and directories are removed.
     *
     * @param string  $file  name of file or directory
     *
     * @return void
     *
     * @access public
     */
    ?>

    Inline

    Inline comments ( // ) allow you to clarify your logic flow in place. These comments will be your life saver when 6 months down the road you want to add a new functionality or track down a bug that keeps slipping through the cracks. I like to annotate things like validation, error handling, DB interactions and the occasional backwards logic.

    <?php
    class mySession
    {
       public function 
    __construct()
        {
           
    // woohoo I'm a constructor that does nothing - lazy slob that I am.
        
    }     
    }
    ?>

    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 7 - Follow our Sitemap