+ Reply to Thread
Results 1 to 3 of 3

Thread: Google Style Guide Update

  1. #1
    Senior Member guvner's Avatar
    Join Date
    Nov 2010
    Location
    Sydney
    Posts
    302

    Google Style Guide Update

    Google published an updated style guide in May.

    Most things are standard I guess, but there are some oddities in there which may cause some of us to revisit our code and scratch heads - (see below for a few of them) but I suppose it's not a bad thing to have "the heavyweight" publishing a 'best practice' coding framework.

    Here's the main page - http://code.google.com/p/google-styleguide/

    Here's the JavaScript guide - http://google-styleguide.googlecode....criptguide.xml

    and here's the one that most of us will be interested in, HTML/CSS - http://google-styleguide.googlecode....mlcssguide.xml

    ===========================

    Things I noticed at first glance...

    Property declarations should be alphabetized i.e.
    Code:
    #example
    {
    	border: 1px solid #000;
    	border-radius: 6px;
    	display: block;
    	font-family: sans-serif;
    	margin: 1em;
    	outline: 0;
    	padding: 10px;
    	text-align: center;
    }
    Makes some sense I guess, but it will separate some declarations that I like to keep together; i.e. font-size, color, text-decoration etc.

    Do not use quotes in url() or unit values after a zero,
    Use short #abc hexadecimal color notation rather than #aabbcc,
    Several mentions about cutting down on white space, but then they recommend indenting with two spaces rather than a tab - I always thought that a tab applied only one space?

    There are plenty more in the guide and probably many I've missed, can you see any quirky ones?

    Mike

  2. #2
    Senior Member bambo's Avatar
    Join Date
    Feb 2011
    Location
    Denmark
    Posts
    3,650
    Forgot the link but this https://github.com/necolas/idiomatic-css should have inspired some WP people to check up on internal CSS. Probably a better general guide.

    I think everyone should do what they want. General rules are for when more than 1 person work on same code or for when 1 person have no clue what to do, heh.

    I stuff - then fix. Big ass separators, something like

    /************************************************** ********** SIDEBAR */

    After check it is

    /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ SIDEBAR ] - */

    But what ever can be right aligned goes.

    Then less visible and normal headlines below/in that section, like

    /* Sidebar, widgets */

    Then easy to find section when scrolling down. Can be an issue with 100s of lines.

    Organizing CSS a bit like Dynamik or just from top to bottom is useful. That was what I needed to learn. Plus never be cheap on comments if there is just a little chance they might be useful later on.

    Also I have a section called TEST, based on bad experiences changing too many things and forgetting on how to go back

    Rest seems to be personal preference. I got headache thinking about order of elements so went with ABC with exception of prefixes. Some might get very annoyed about that = it is crap then! Idiomatic suggest what ever suits you. As long as not wrong that is what everyone should use.

    2 lines saved, loss of visibilty is zero to me. Slight improvement actually, don't like all that space or tab over 3 characters

    Code:
    #example {
    	border: 1px solid #000;
    	border-radius: 6px;
    	display: block;
    	font-family: sans-serif;
    	margin: 1em;
    	outline: 0;
    	padding: 10px;
    	text-align: center; }
    Last edited by bambo; 07-12-2012 at 06:36 PM.

  3. #3
    Senior Member bambo's Avatar
    Join Date
    Feb 2011
    Location
    Denmark
    Posts
    3,650
    I do like Google devs. - check this under indention http://google-styleguide.googlecode....ml#Indentation

    Code:
     Indent by 2 spaces at a time.
    
    Don’t use tabs or mix tabs and spaces for indentation.
    Pretty sure no other "authority" on the internet will make such a recommendation. MUST be tabs or you are doing it WRONG! - and to make it worse some even suggest 8 stupid character wide tab length. Google don't care

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts