!SLIDE bullets incremental left
!SLIDE
!SLIDE bullets left
- 晦澀:難以閱讀,無法了解意圖
- 不需要的重複:相同概念的程式碼被複製貼上重複使用
- 黏滯:彈性不夠,把事情做對比做錯還難
- 固定: 難以分解,讓程式再重用
- 脆弱: 一旦修改,別的無關地方也炸到
- 僵硬 : 難以修改,每改一處牽一髮動全身
!SLIDE center
!SLIDE bullets left
- Don't know how to code
- IT JUST WORKS!
- PHP, .NET, JAVA coding tyle
- unfamiliar with Rails way
!SLIDE bullets xleft
- 不好的程式寫作習慣
- 不適當的 Coding Style
- 隨意亂扔程式碼
- 到處複製貼上程式碼
- 濫用 Framework / ORM
- 重複發明輪子
!SLIDE
!SLIDE code left
def t_tags t_list.join(" ") end
def tokenized_tags tag_list.join(" ") end
!SLIDE
!SLIDE code left
case game_typewhen "1" # do_something_x when "2" # do_something_y when "3" # do_something_z else # redirect_to root_path end
!SLIDE code left
case game_type when "rpg" # do_somehting_x when "strategy" # do_something_y when "fps" # do_something_y else # redirect_to root_path end
!SLIDE
!SLIDE code
if color=="red" print "red" elsif color="green" print "green" elsif orignal_color=="yellow" print "yellow" else print "orange" end
!SLIDE code
if original_color == "yellow" print "yellow" return endcase color when "red" print "red" when "green" print "green" else print "orange" end
!SLIDE
!SLIDE code
post.is_hide
post.is_hidden
!SLIDE code
post.is_spam?
post.is_spam!
!SLIDE
!SLIDE code
attacker / defender
sender / reciever
!SLIDE
!SLIDE center
!SLIDE
!SLIDE center
!SLIDE center
!SLIDE center
!SLIDE bullets incremental left
- Use 2 space indent, no tabs.
- Use snake_case for methods.
- Use CamelCase for classes and modules.
- Use SCREAMIN_SNAKE_CASE for other constants.
!SLIDE bullets incremental left
- 大範圍的程式碼使用 do end。1-2 行使用 lambda {}
- 定義 method 要加括號 ()。除非是宣告或 command
- 加括號:hello(name) # 一般 method
- 可不加括號: attr_accessible :nickname # 宣告或 command
!SLIDE center
!SLIDE
!SLIDE