Buổi Coding dojo thứ 3 của CocoDojo dành cho coding lovers.
Thử thách #3: Viết 1 chương trình Tính tổng điểm của trò chơi Bowling sau khi người chơi hoàn thành 10 frame (lượt ném).
Chi tiết: http://tapchilaptrinh.wordpress.com/2012/11/01/kata-bowling/
Homepage: http://cocodojo.github.com/
Facebook:
http://www.facebook.com/groups/160416774098228/
1. Bowling Kata
CocoDojo #3
07-12-2012
Presenter:
Nguyễn Tuấn Anh && Nguyễn Trung
Tuyến
2. Bowling game: how to play
• Bạn ném 10 lượt (frame)
• Mỗi frame, bạn có 2 lần ném (roll) - 10 pin
• Strike frame (X): lần ném 1 đổ 10 pin
• Spare frame (/): sau lần ném 2 đổ 10 pin
• Open frame: sau lần ném 2 đổ <10 pin
– Final frame (10th frame): ( max: 3 lần ném)
» Lần 1: strike được ném thêm 2 lần
» Lần 2: spare được ném thêm 1 lần
3. Bowling game: calculate score
• Score of 1 game = total score of 10 frames
• Open frame = roll_1 + roll_2
• Strike frame= 10 + (score of) 2 next rolls
• Spare frame = 10 + (score of) 1 next roll
– Final frame (10th frame):
» Open frame: roll_1 + roll_2
» Lần 1: strike score= 10 + roll_1 + roll_2
» Lần 2: spare score= 10 + roll_1
5. Bowling Kata: What we do
• Calculate score of 1 game bowling
• Input: valid sequence of rolls, i.e :
» XXXXXXXXXXXX
»1/2/3/4/5/6/7/8/9/X12
»1-2-3-4-5-6-7-8-9-10
»-/ -/ -/ -/ -/ -/ -/ -/ -/ -/
6. Bowling Kata: What we NOT do
• Calculate score of intermediate frames
• Don’t check : valid of rolls && frames
»i.e :
»XXXXXXXXXXXXYYY
»1/2/3/4/5/6/7/8////X12
»1-2-3-4-5-6-7-8-9-10-11
7. Bowling Kata: How we will do
• Kata : không phải thứ để bạn ngắm nghía
•Kata: là 1 bài tập lập trình để
nâng cao khả năng lập trình của
bạn bằng cách thực hiện nó
ngày này qua ngày khác
8. Bowling Kata: How we will do
• In which way will we solve this kata?
– a simple minder way?
– a stupid way?
– an elegant way?
– an OOP way?
»HOW ABOUT YOU?
» Which ways did you do?
» Which ways you hate?
» Which ways you like?
» Which ways you love the most?
9. Bowling Kata: How we will do
• Bowling Kata: Chúng ta (bạn và tôi) sẽ
thực hành nó như thế nào?
– trong không khí vui vẻ && cởi mở
– theo dõi 1 cặp lập trình viên trình bày giải
pháp cho bài kata dùng TDD và baby steps
– TDD: Test Driven Development - Phát triển dựa trên
kiểm thử (Test-Driven Development-TDD) là một phương
pháp tiếp cận cải tiến để phát triển phần mềm trong đó
kết hợp phương pháp Phát triển kiểm thử trước (Test
First Development) và phương pháp Điều chỉnh lại mã
nguồn (Refactoring)
10. CocoDojo : Đôi điều
bạn cần biết
» Homepage: http://cocodojo.github.com/
» Facebook: http://www.facebook.com/groups/160416774098228/
» Chi tiết: Bowling Kata
http://tapchilaptrinh.wordpress.com/2012/11/01/kata-
bowling/
» Coding dojo là gì: https://tapchilaptrinh.wordpress.com/2012/09/29/coding-
dojo-la-gi/
» TDD: http://www.jamesshore.com/Agile-Book/test_driven_development.html
» Pair programing: (Tiếng Việt) http://nguyentrungtuyen.me/pair-programming-
what-is-it-why-need-it-how-to-do-it/
» Code refactoring: https://tapchilaptrinh.wordpress.com/2012/10/05/tai-cau-
truc-ma-nguon/
» Hướng dẫn reflection:
https://duongtrongtan.wordpress.com/2012/05/28/huong-dan-reflection/