openlayers / ol2

OpenLayers v2 - deprecated!
Other
1.48k stars 771 forks source link

Code Style Guide #308

Open pjeweb opened 12 years ago

pjeweb commented 12 years ago

OpenLayers' code should be more consistent in its style. Suggestions: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml or good old Crockford: http://javascript.crockford.com/code.html.

Also see #310 and #24.

tschaub commented 12 years ago

See http://trac.osgeo.org/openlayers/wiki/CodingStandards

Not saying it's complete, but it is related. At some point we'll need to deal with old wiki content.

pjeweb commented 12 years ago

So it would help to consolidate the collection of links and information in a simple markdown file? I will write one!

pjeweb commented 12 years ago

Then I have some questions (and these are just some):


I've seen various versions of for statements as: Question: What's the right way?

for (var i=0, len=jsFiles.length; i<len; ++i) {

Source: http://trac.osgeo.org/openlayers/wiki/CodingStandards -> Conventions.

Also seen (and as Crockford says):

var i,
    len = jsFiles.length;

for (i = 0; i < len; i += 1) {

Also I've seen whitespaces like: Questions: Is that right? Is 80/79 chars per line really still useful?

        method:       'post',
        asynchronous: true,
        contentType:  'application/xml',
        parameters:   ''

and

        olBounds = new OpenLayers.Bounds(sw.lon, 
                                         sw.lat, 
                                         ne.lon, 
                                         ne.lat );