What's new? | Help | Directory | Sign in
Google
             
Search
for
Updated Sep 29, 2008 by pamela.fox
JavascriptCodingConventions  
Coding conventions to be followed in Javascript files here.

Introduction

All Javascript files must follow these coding conventions before they can be committed to the release project.

Language Rules

Style Rules

Naming

Formatting

Comments

  • Should generally follow JSDoc conventions.
  • Inline comments are useful if the code is unclear.
  • Each function must be commented (purpose, @param, @return):
  • /**
     * Creates a flat icon based on the specified options in the 
     *     {@link MarkerIconOptions} argument.
     *     Supported options are: width, height, primaryColor,
     *     shadowColor, label, labelColor, labelSize, and shape..
     * @param {MarkerIconOptions} [opts]
     * @return {GIcon}
     */
  • Copyright, author, license, plus short description of file at top of code:
  • /**
     * @name MapIconMaker
     * @version 1.1
     * @author Pamela Fox
     * @copyright (c) 2008 Pamela Fox
     * @fileoverview This gives you static functions for creating dynamically
     *     sized and colored marker icons using the Charts API marker output.
     */
    
    /*
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License. 
     */

Comment by krokicki, Sep 25, 2008

Is there a policy for dependencies? For example, if I wanted to use jQuery in my code. It seems the existing projects are standalone, which has its benefits, but so does using existing libraries.

Comment by chrismarx, Sep 28, 2008

Hi, I was told to avoid using any frameworks that could make it hard for end users to understand/modify the project. I wanted to use jQuery too!!


Sign in to add a comment