Jump to content

Useful Tool: Comment Headings


davestewart

Recommended Posts

I wrote a small Flash app last year to help me out with better-organising and navigating my code called Comment Headings, and I've just updated it.

 

It basically allows you to type in section titles and have them be produced as ASCII art style headings, which makes it much easier to navigate scripts, as it's very easy to see what's where. For example:

 


    // ------------------------------------------------------------------------------------------------------------------------
    //
    //    ██████      ██              ██             ██   ██        ██   ██             ██       
    //    ██  ██                      ██             ███ ███        ██   ██             ██       
    //    ██  ██ ████ ██ ██ ██ █████ █████ █████     ███████ █████ █████ █████ █████ █████ █████ 
    //    ██████ ██   ██ ██ ██    ██  ██   ██ ██     ██ █ ██ ██ ██  ██   ██ ██ ██ ██ ██ ██ ██    
    //    ██     ██   ██ ██ ██ █████  ██   █████     ██   ██ █████  ██   ██ ██ ██ ██ ██ ██ █████ 
    //    ██     ██   ██  ███  ██ ██  ██   ██        ██   ██ ██     ██   ██ ██ ██ ██ ██ ██    ██ 
    //    ██     ██   ██  ███  █████  ████ █████     ██   ██ █████  ████ ██ ██ █████ █████ █████ 
    //
    // ------------------------------------------------------------------------------------------------------------------------
    // Private Methods

        private function doSomething()
        {
            // function body
        }

        private function doSomethingElse()
        {
            // function body
        }

        // etc

 

It now has options to let you fully customise the input and output using an XML preferences file.

 

For example, you could set up different input headings (Variables, Methods, Initialize, etc) depending on whether you were building class or page code, or you could set up different comment delimiters depending on whether you were coding PHP or VB or something else.

 

If you're using something like Eclipse, then it may not be as useful, but if organising code in a more basic editor, I find I can't work without it now!

 

Test, use, and download it from here: http://www.keyframesandcode.com/code/development/comment-headings/

 

Cheers,

Dave

Link to comment
Share on other sites

Not sure how this would really help. Just huge headings. Doesn't display what the methods, variables do, return etc. Access levels of methods, member variables are easily read with the public, protected, private syntax.

 

Class commenting should look as follows:

 


    /**
     * Available frontends
     * 
     * @var array $availableFrontends array of frontend name (string)
     */
    public static $availableFrontends = array('Core', 'Output', 'Class', 'File', 'Function', 'Page');


    /**
     * Factory
     * 
     * @param string $frontend frontend name
     * @param string $backend backend name
     * @param array $frontendOptions associative array of options for the corresponding frontend constructor
     * @param array $backendOptions associative array of options for the corresponding backend constructor
     */
    public static function factory($frontend, $backend, $frontendOptions = array(), $backendOptions = array()) {

Link to comment
Share on other sites

Hi Neil,

 

It's certainly not supposed to replace JavaDoc commenting, or any other documentation for that matter!

 

All it is, is a large visual reference to areas of your script, so when you're scrolling through large (or even small) scripts you can immediately tell which section you're in.

 

The point is with simple characters -, =, * etc, there's only so much emphasis you can make to a heading, and it's often a lot of legwork. This is just a tool to make that easier.

 

You don't have to stick to headings like "Private Methods", you could have "Front end", "File tasks", "Notes", whatever you like.

 

:D

Link to comment
Share on other sites

I thought it might be helpful to briefly show the comparison between a comment-headered file and a normal file, and how it's easier to skim through the one with comment headings:

 

 

And no, it doesn't affect headers.

 

my man, your headings dont work on a MAC in firefox, i think its cos the character is not standard

Link to comment
Share on other sites

That is not really large, although I try to stay below 1000 per file. Sometimes it's not possible though.

I'm now working on a GUI that hasn't got a fourth of it's planned functionality yet, and is already over 1000 lines. This will be a hog and I'm thinking of a way to split it somehow.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.