dmitry-solomadin / skwibl

Realtime collaboration service.
http://skwibl.com
1 stars 0 forks source link

Remove useless construction to make code readable #185

Closed yuri-karadzhov closed 11 years ago

yuri-karadzhov commented 11 years ago

I will clear the code myself, but please, use correct construction in the future

if a == "true" then true else false ----> a is "true"
a = {} unless a ----> a = a or {}
if a then a else b ----> a or b
b = a if a ----> b = a
b = if a then a else undefined ----> b = a
c = if a then b else undefined ----> c = b if a
a.b.c if a and a.b ----> a?.b?.c
a = a + b ----> a += b
if a if b c ----> if a and b c
if a isnt 0 ----> if a

(I extend the list when found others)

dmitry-solomadin commented 11 years ago

I strongly disagree on this

if a isnt 0 ----> if a
if a is 0 ----> unless a

Left part much readable because you explicitly compare it to zero, because it is length or some counter.

yuri-karadzhov commented 11 years ago

I strongly disagree with direct comparing with zero.

if a --- standart construction in lots of languages
if a is 0 ---> if not a

We can use if not if You have troubles with unless, but nobody compares the value with zero directly.

dmitry-solomadin commented 11 years ago

We have very different programming experience I guess.

yuri-karadzhov commented 11 years ago

It's C standard.

dmitry-solomadin commented 11 years ago

It's mostly done. Closing.

yuri-karadzhov commented 11 years ago
for readOnlyActivity in readOnlyActivities
    return true if activity.type is readOnlyActivity
  return false
activity.type in readOnlyActivities