Scrum Gathering 2012 Shanghai_工程实践与技术卓越分会场:编程练习(尹哲)

844 views
773 views

Published on

讲师 :尹哲
尹哲是Odd-e团队中的一名敏捷教练。他在软件行业有超过12年的经验,其中大部分是在电信领域。他有丰富的培训和咨询软件工程的经验,如测试驱动开发,系统工程实践以及分析实践等。他在敏捷与精益教练方面也很有经验,尤其是Scrum。他在研发管理和软件设计两方面都有很强的能力。他同是还是敏捷社区和开源软件的积极参与者.

话题介绍:
专业的软件工程师需要通过不断的练习来保持自己的最佳状态和自我提升。该话题将会介绍两种不同类型的编程练习,一种是解决一个特定的问题,另一种则是提高团队协作和对编程设计原则的理解。同时,话题中将有一些关于测试驱动开发和软件设计的内容,让听众一起来思考。

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
844
On SlideShare
0
From Embeds
0
Number of Embeds
97
Actions
Shares
0
Downloads
24
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Scrum Gathering 2012 Shanghai_工程实践与技术卓越分会场:编程练习(尹哲)

  1. 1. Programming Exercises12年6月5日星期二
  2. 2. Who am I? 尹哲:terry@odd-e.com twitter: terryyin weibo: terry尹哲 212年6月5日星期二
  3. 3. Programming Exercises12年6月5日星期二
  4. 4. Why Programming Exercises? 412年6月5日星期二
  5. 5. 512年6月5日星期二
  6. 6. Question Does software company need to train programmers? 612年6月5日星期二
  7. 7. Leonhard Euler Dojo vs. 712年6月5日星期二
  8. 8. What is ProjectEuler.net? 812年6月5日星期二
  9. 9. ProjectEuler.net "Project Euler exists to encourage, challenge, and develop the skills and enjoyment of anyone with an interest in the fascinating world of mathematics." • Project Euler is a series of challenging mathematical/computer programming problems that requires more than just mathematical insights to solve. 912年6月5日星期二
  10. 10. ProjectEuler.net 1012年6月5日星期二
  11. 11. ProjectEuler.net 1112年6月5日星期二
  12. 12. Expectations Mathematics So lution implementing Hig h perfor mance co d ing So lving problem ind ivi dually 1212年6月5日星期二
  13. 13. Example: Quick & Dirty Once you solved a problem, you are entitled to join the forum for this problem.You can share your solution with the other people who have also solved it. And the post usually start with this sentence: Good coding habit? 1312年6月5日星期二
  14. 14. Another Example 1412年6月5日星期二
  15. 15. int i, j, k, n, sum; int factorial[10000]; int* getfactorial(int n) { factorial[0] = 1; k = 0; for(i = 2; i <= n; i++) { • It’s too simple for for(j = 0; j <= k; j++) factorial[j] *= i; Java, Ruby or Python, for(j = 0; j <= k; j++) for which they can { if(factorial[j] >= 10) handle big numbers by { factorial[j+1] += (factorial[j] - (factorial[j] % 10)) / 10; default. factorial[j] = factorial[j] % 10; • So let’s look at C/C++. if(j == k) k++; • Real code copied from } } the forum. } return factorial; } int getsum(int* array, int k) { sum = 0; for(i = 0; i <= k; i++) sum += array[i]; return sum; } int main() { int* factorial = getfactorial(n); sum = getsum(factorial, k); cout << "nThe sum of the digits of " << n << "! is " << sum << ".n"; return 0; } 1512年6月5日星期二
  16. 16. 1612年6月5日星期二
  17. 17. Big number again. Ha ha, I did that before! Let me reuse it... 1712年6月5日星期二
  18. 18. #include<iostream> using namespace std; int i, j, k, n, sum; int factorial[10000]; Why the big number is named ‘factorial’ int* getfactorial(int n) { in my previous implementation? factorial[0] = 1; k = 0; for(i = 2; i <= n; i++) { for(j = 0; j <= k; j++) factorial[j] *= i; for(j = 0; j <= k; j++) Where’s the code for big number? { if(factorial[j] >= 10) { factorial[j+1] += (factorial[j] - (factorial[j] % 10)) / 10; factorial[j] = factorial[j] % 10; if(j == k) k++; } } } return factorial; } 1812年6月5日星期二
  19. 19. #include <stdio.h> #define NUMB 120 // 9 * 120 = 1080 total digits. #define SIZE 1000000000 // 9 digit numbers int main() { int i = 0; int j = 0; int bigNum1[NUMB]; int bigNum2[NUMB]; int bigNum3[NUMB]; int counter = 0; for (i = 0; i < NUMB; i++) { bigNum1 = 0; bigNum2 = 0; bigNum3 = 0; } bigNum1[0] = 1; OK, too hard to reuse. It’s not bigNum2[0] = 1; counter = 2; that hard to invent the wheel again. i = 0; while (i == 0) { counter++; for (j = 0; j < NUMB; j++) { bigNum3[j] = bigNum2[j] + bigNum1[j]; } for (j = 0; j < NUMB-1; j++) { while (bigNum3[j] >= SIZE) { bigNum3[j] -= SIZE; bigNum3[j+1]++; Design? } } if (bigNum3[111] >= 1) break; for (j = 0; j < NUMB; j++) { bigNum1[j] = bigNum2[j]; bigNum2[j] = bigNum3[j]; } } printf("n"); printf("P025 answer = %u", counter); } 1912年6月5日星期二
  20. 20. ing exercises Problem so lv tant skills ✓ Train ver y impor w as inter vie ✓Often use d ques tions i n skills in ✓ Probab ly also tra n able co de, maki ng maintai a little. •Don’t do it before bed time... 2012年6月5日星期二
  21. 21. What is Cyber Dojo? 2112年6月5日星期二
  22. 22. 2212年6月5日星期二
  23. 23. 2312年6月5日星期二
  24. 24. 2412年6月5日星期二
  25. 25. RED - GREEN - REFACTOR 2512年6月5日星期二
  26. 26. 2612年6月5日星期二
  27. 27. 2712年6月5日星期二
  28. 28. 2812年6月5日星期二
  29. 29. Which One Do You Prefer? 2912年6月5日星期二
  30. 30. Poker Hands 3012年6月5日星期二
  31. 31. Poker Hands Kata 3112年6月5日星期二
  32. 32. Poker Hands in ProjectEuler • This is not a very hard problem to solve, comparing to most of the problems listed in ProjectEuler.net • But it’s hard to solve it without bugs if you don’t have unit tests. • Problem 54 in projectEuler.net 3212年6月5日星期二
  33. 33. Example: Complicated Transaction 3312年6月5日星期二
  34. 34. Why Did I Do It Right With Only One Try? 3412年6月5日星期二
  35. 35. TEST(poker_hand, comparing){ CHECK(pokerHand("4H 5C 6S 7S TD")< pokerHand("2C 3S 7S 8D KD")); CHECK(!(pokerHand("4H 5C 6S 7S KD")< pokerHand("2C 3S 7S 8D TD"))); CHECK(pokerHand("4H 5C 6S 7S KD")> pokerHand("2C 3S 7S 8D TD")); } TEST(poker_hand, compare_cards){ CHECK(pokerHand("3H 5C 6S 7S 8D")< pokerHand("4H 5C 6S 7S 9D")); CHECK(pokerHand("3H 5C 6S 7S 9D")< pokerHand("4H 5C 6S 7S TD")); CHECK(pokerHand("3H 5C 6S 7S TD")< pokerHand("4H 5C 6S 7S JD")); CHECK(pokerHand("3H 5C 6S 7S JD")< pokerHand("4H 5C 6S 7S QD")); CHECK(pokerHand("3H 5C 6S 7S QD")< pokerHand("4H 5C 6S 7S KD")); CHECK(pokerHand("3H 5C 6S 7S KD")< pokerHand("4H 5C 6S 7S AD")); } TEST(poker_hand, compare_high_cards_2nd){ CHECK(pokerHand("3H 5C 6S 7S 9D")< pokerHand("3H 5C 6S 8S 9D")); } TEST(poker_hand, compare_high_cards_3nd_4th_5th){ CHECK(pokerHand("3H 5C 6S 8S 9D")< pokerHand("3H 5C 7S 8S 9D")); CHECK(pokerHand("3H 4C 7S 8S 9D")< pokerHand("3H 5C 7S 8S 9D")); CHECK(pokerHand("2H 5C 7S 8S 9D")< pokerHand("3H 5C 7S 8S 9D")); } TEST(poker_hand, compare_high_card_and_one_pair){ CHECK(pokerHand("3H 5C 6S 8S 9D")< pokerHand("3H 5C 7S 8S 8D")); } TEST(poker_hand, compare_one_pairs){ CHECK(pokerHand("3H 5C 6S 9S 9D")> pokerHand("3H 5C 7S 8S 8D")); CHECK(pokerHand("5C 6S 9S 9D KD")> pokerHand("5C 7S 8S 8D AD")); CHECK(pokerHand("5C 6S 9S 9D KD")< pokerHand("5C 7S 9S 9D AD")); } ... 3512年6月5日星期二
  36. 36. Do both exercises. Alone and with the others. Always use good practices. Have fun. 3612年6月5日星期二
  37. 37. Discuss Training in workshop Develop in concurrence Deliver for acceptance 3712年6月5日星期二
  38. 38. Odd-e Certified Scrum Developer • One week course simulating how it feels to be on a Scrum project - Realistic exercise to work on as a team - Topics covered: A-TDD, Build Automation, Sprint Planning, Pair Programming, Continuous Integration, Test-Driven Development, Working in teams, Collective Code Ownership, Mocking, Code Smells & Refactoring, Good unit tests,Emergent Design, Working with Legacy Code, Craftsmanship - Maximum 10 people, in Odd-e office - Java and C++ version - Fulfills the ScurmAlliance CSD More info at: http://www.odd-e.com/courses.php?id=201205SingaporeCSD 3812年6月5日星期二
  39. 39. Coaching 3912年6月5日星期二

×