Various coding styles I hate seeing. It's a rant, but a fun one. Uses Spiderman to help illustrate my angst.
This talk was originally given at Cluj.pm, on November 7th, 2013.
4. REALLY STUPID STUFF
$ , $ ,$ , $ , $ , $ , $ , $
a b i j k l m n
$,$,$,$, $,$,$
f u c k y o u
Trailing spaces STOP IT!
$a,@ra,%ah
vr ary hs
5. TABS VS. SPACES
The eternal struggle
Do not mix tabs and spaces
Do NOT mix tabs and spaces
DO NOT mix tabs and spaces
DO NOT MIX TABS AND SPACES!
Best rule? No tabs, only spaces
6. MISUNDERSTANDINGS
m pwithout checking value
a
#mpEP,IT
a XRLS
m %gs =mp+ $ = $is$}'g' ) ky %is
y ae
a ( _ > kd{_{ae} , es kd;
#mpBOKLS
a LC IT
m @otd=mp {$-[]
y sre
a
_>0
}
sr {$-[]<>$-[] }
ot
a>1 = b>1
mp {[$,ceku(_ ]}@ie;
a
_ hcsm$)
szs
C-style f rf r a h
o/ oec
#frfrahLS
o/oec IT
m @is=q<en jf jh jci jmjh ja jn jd js>
y kd
wjny ef on ake i on on ue ue oh;
fr(m $ =0 $ <@is $+ ){
o
y i
; i
kd; i+
sy">$is$];
a - kd[i"
}
frahm $i (kd){
oec y kd @is
sy">$i"
a - kd;
}
sy">$"fr@is
a - _ o kd;
7. SWITCHES
i
f
(oe
$n) {.}
..
esf(to
li $w) {.}
..
esf(tre {.}
li $he) ..
es
le
{.}
..
m %ipth=(
y dsac
$n
oe = sb{.}
> u ..,
$w
to = sb{.}
> u ..,
$he = sb{.}
tre > u ..,
)
;
i (eit $ipth$nu}){
f
xss dsac{ipt
$ipth$nu}>..;
dsac{ipt-(.)
}es {.}
le ..
8. EMPTY IF CLAUSE
i (smtig {
f $oehn)
#d ntig
o ohn
}es {
le
#teata wr
h cul ok
}
9. RETURN VARIABLES
m $eun
y rtr;
i (ti){
f $hs
..
.
$eun='hs;
rtr
ti'
}esf(aohrtig {
li $nte_hn)
..
.
$eun='ht;
rtr
ta'
}
rtr $eun
eun rtr;
12. GOTO HELL;
NOT FOR WORKFLOW!
#Clbljms
ae up
gt HL;
oo EL
#smweees
oehr le
HL:
EL
cniu_BxCascd(;
otneDI_ls_oe)
#oerdstecretfaei tesak
vrie h urn rm n h tc
#go,we ncsay
od hn eesr
gt &yfnto;
oo m_ucin
13. WHY?
Because code is alive and grows
Sometimes to ridiculous age
You might not be the last
And the next might know your address