1

Use spaces liberally throughout your code. “When in doubt, space it out.”

In the above sentence, what does "space it out" mean?

Source: https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/#spacing

  • 1
    Actually, you can find the definition of "space out" in a dictionary, e.g., Macmillan defines it like this: "to arrange objects, events, activities, etc. so that they are a particular time or distance apart". This use is a bit like a pun because as it suggests you would use spaces to space it out. If you'd followed the link in your page, "The WordPress JavaScript Coding Standards are adapted from the jQuery JavaScript Style Guide", you would've seen their clear Bad/Good Examples. – Damkerng T. Jun 9 '16 at 9:43
0

The construction

(verb) + it out

can be used to emphasize a verb in the sense to do that verb more, to do it until its maximum capacity, or to do it completely. So your example means

use more spaces

In other words, it means exactly what the first part says

Use spaces liberally throughout your code

There are other examples:

  • Talk it out
    To talk until you are satisfied, or until you express all your burdensome emotions

  • Work it out
    To work on a problem until it is finished or fixed

  • Stretch it out
    To stretch something, like a muscle until it is warmed up, or a rubberband until it is about to break

  • Stick it out
    To continue to do something to its end

There are other examples.

Further, the meaning I gave is not strict. Here is a special case.

cut it out

It means to stop something completely. For example, if you are trying to study, but your little brother or sister keeps asking you to play, you might tell him or her "Cut it out!"

6

In your example

space it out

means to add spaces (or whitespaces) to make the code easier for humans to read.

Consider the difference between

def myMethod(a,b,c)if(a==b)t=0;elseif(b==c)t=a;else t=c;end;return t;end

and

def myMethod(a,b,c)
    if(a==b)
        t=0;
    elseif(b==c)
        t=a;
    else
        t=c;
    end;
    return t;
end

the nesting, using additional whitespace indentation, more clearly shows how the code will execute given different conditions. In some circumstances, behind the scenes, the additional whitespace is automatically removed (since the computer does not need it) in a process call "minification".

Your example also uses the well known construction since "doubt" and "out" rhyme

when in doubt, something it out

where something can be any verb that goes with "out" as long as the context makes sense

when in doubt, white it out (with correction fluid)
when in doubt, scream it out
when in doubt, cut it out (a possible saying by surgeons)
when in doubt, ride it out
when in doubt, wait it out

  • +1 for the neat code (I'd have used a case structure though :) ) – PerryW Jun 9 '16 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.