Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RubyConf China 17/11/2012 - Become a Better Developer You Can

Fred Wu
November 17, 2012

RubyConf China 17/11/2012 - Become a Better Developer You Can

Fred Wu

November 17, 2012
Tweet

More Decks by Fred Wu

Other Decks in Programming

Transcript

  1. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem 4 Saturday, 17 November 12
  2. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem • 1997 Made my first ever HTML web page in Microsoft Frontpage Express 4 Saturday, 17 November 12
  3. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem • 1997 Made my first ever HTML web page in Microsoft Frontpage Express • 1998 Moved to Australia 4 Saturday, 17 November 12
  4. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem • 1997 Made my first ever HTML web page in Microsoft Frontpage Express • 1998 Moved to Australia • 2001 Started playing with Perl (雷傲), ASP (动⺴⽹网) and PHP (Discuz!) forum software 4 Saturday, 17 November 12
  5. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem • 1997 Made my first ever HTML web page in Microsoft Frontpage Express • 1998 Moved to Australia • 2001 Started playing with Perl (雷傲), ASP (动⺴⽹网) and PHP (Discuz!) forum software • 2004 Started learning PHP and JavaScript in TAFE (pre-university bridge) 4 Saturday, 17 November 12
  6. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem • 1997 Made my first ever HTML web page in Microsoft Frontpage Express • 1998 Moved to Australia • 2001 Started playing with Perl (雷傲), ASP (动⺴⽹网) and PHP (Discuz!) forum software • 2004 Started learning PHP and JavaScript in TAFE (pre-university bridge) • 2006 Started working part-time as a junior developer whilst studying in university 4 Saturday, 17 November 12
  7. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem • 1997 Made my first ever HTML web page in Microsoft Frontpage Express • 1998 Moved to Australia • 2001 Started playing with Perl (雷傲), ASP (动⺴⽹网) and PHP (Discuz!) forum software • 2004 Started learning PHP and JavaScript in TAFE (pre-university bridge) • 2006 Started working part-time as a junior developer whilst studying in university • 2006 Discovered Ruby and Ruby on Rails, and switched to OS X because of Textmate 4 Saturday, 17 November 12
  8. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem • 1997 Made my first ever HTML web page in Microsoft Frontpage Express • 1998 Moved to Australia • 2001 Started playing with Perl (雷傲), ASP (动⺴⽹网) and PHP (Discuz!) forum software • 2004 Started learning PHP and JavaScript in TAFE (pre-university bridge) • 2006 Started working part-time as a junior developer whilst studying in university • 2006 Discovered Ruby and Ruby on Rails, and switched to OS X because of Textmate • 2008 Started professionally as a web developer (HTML, CSS, PHP and JavaScript) 4 Saturday, 17 November 12
  9. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem • 1997 Made my first ever HTML web page in Microsoft Frontpage Express • 1998 Moved to Australia • 2001 Started playing with Perl (雷傲), ASP (动⺴⽹网) and PHP (Discuz!) forum software • 2004 Started learning PHP and JavaScript in TAFE (pre-university bridge) • 2006 Started working part-time as a junior developer whilst studying in university • 2006 Discovered Ruby and Ruby on Rails, and switched to OS X because of Textmate • 2008 Started professionally as a web developer (HTML, CSS, PHP and JavaScript) • 2010 Started programming in Ruby full time (mostly) 4 Saturday, 17 November 12
  10. • 1997 Got my first computer (Intel Pentium MMX 166Mhz)

    • 1997 Started using BBS (上海热线) and the Internet via 33.6Kbps modem • 1997 Made my first ever HTML web page in Microsoft Frontpage Express • 1998 Moved to Australia • 2001 Started playing with Perl (雷傲), ASP (动⺴⽹网) and PHP (Discuz!) forum software • 2004 Started learning PHP and JavaScript in TAFE (pre-university bridge) • 2006 Started working part-time as a junior developer whilst studying in university • 2006 Discovered Ruby and Ruby on Rails, and switched to OS X because of Textmate • 2008 Started professionally as a web developer (HTML, CSS, PHP and JavaScript) • 2010 Started programming in Ruby full time (mostly) • 2010 Started contributing to many open source ruby projects, including Ruby on Rails 4 Saturday, 17 November 12
  11. Dr Nic Williams Author of Rails Textmate bundle, works at

    Engine Yard Ryan Bigg Author of Rails 3 in Action, 2011 Ruby Hero Pat Allan Author of Thinking Sphinx, 2009 Ruby Hero Xavier Shay Author of Cane and Enki, works at Square Ben Schwarz Member of W3C’s CSS Working Group Darcy Laycock Author of API Smith, 2011 Ruby Hero Justin French Author of Formtastic Daniel Neighman Author of Warden, works at Square Ben Hoskings Author of Babushka Marcus Crafter Author of Sprinkle Charlie Somerville Author of Slash language, a talented 18 year old! Jack Chen (Chendo) Contributor to iTerm2 Mikel Lindsaar Author of Mail, rails core committer John Barton Cofounder of Goodfil.ms, dev manager of Envato for 3+ years Paul Annesley Built 99designs, works at SitePoint Gareth Townsend Founder of Melbourne Cocoaheads Ivan Vanderbyl Founder of Crashlog Glen Maddern Cofounder of Goodfil.ms Alan Harper Author of Rubyzip James Healy Author of PDF::Reader, maintainer of Prawn Florian Hanke Author of Picky 6 Saturday, 17 November 12
  12. DISCLAIMER I am still a n00b. ⼩小⼩小菜⻦鸟。 But I care,

    so I share. 抛砖引⽟玉。 7 Saturday, 17 November 12
  13. THOUGHTS ON SOFTWARE DEVELOPMENT • Second system syndrome - avoid

    total rewrites. 第⼆二系统综合症——避免重写。 8 Saturday, 17 November 12
  14. THOUGHTS ON SOFTWARE DEVELOPMENT • Second system syndrome - avoid

    total rewrites. 第⼆二系统综合症——避免重写。 • Software engineering is like playing Starcraft - always check your mini-map. 软件⼯工程有如星际争霸——需经常关注迷你地图,以⼤大局为重。 8 Saturday, 17 November 12
  15. THOUGHTS ON SOFTWARE DEVELOPMENT • Second system syndrome - avoid

    total rewrites. 第⼆二系统综合症——避免重写。 • Software engineering is like playing Starcraft - always check your mini-map. 软件⼯工程有如星际争霸——需经常关注迷你地图,以⼤大局为重。 • Experience is as important as talent, if not more important. 经验与天赋同重要。 8 Saturday, 17 November 12
  16. THOUGHTS ON SOFTWARE DEVELOPMENT • Second system syndrome - avoid

    total rewrites. 第⼆二系统综合症——避免重写。 • Software engineering is like playing Starcraft - always check your mini-map. 软件⼯工程有如星际争霸——需经常关注迷你地图,以⼤大局为重。 • Experience is as important as talent, if not more important. 经验与天赋同重要。 • Technical debt is a debt, the longer you wait, the more interests you pay. 技术债务——拖⽋欠越久,偿还越多。 8 Saturday, 17 November 12
  17. THOUGHTS ON SOFTWARE DEVELOPMENT • Second system syndrome - avoid

    total rewrites. 第⼆二系统综合症——避免重写。 • Software engineering is like playing Starcraft - always check your mini-map. 软件⼯工程有如星际争霸——需经常关注迷你地图,以⼤大局为重。 • Experience is as important as talent, if not more important. 经验与天赋同重要。 • Technical debt is a debt, the longer you wait, the more interests you pay. 技术债务——拖⽋欠越久,偿还越多。 • Choose the application architecture wisely. 谨慎选择软件架构。 8 Saturday, 17 November 12
  18. APPLICATION ARCHITECTURE SHOWCASE • We need a profile system to

    hold user data. ⽤用户帐户系统。 9 Saturday, 17 November 12
  19. APPLICATION ARCHITECTURE SHOWCASE • We need a profile system to

    hold user data. ⽤用户帐户系统。 • The profile system will potentially be used standalone. ⽤用户帐户系统未来可能会被独⽴立使⽤用。 9 Saturday, 17 November 12
  20. APPLICATION ARCHITECTURE SHOWCASE • We need a profile system to

    hold user data. ⽤用户帐户系统。 • The profile system will potentially be used standalone. ⽤用户帐户系统未来可能会被独⽴立使⽤用。 • We need plugin-able “modules”. 需可插⼊入式模块系统。 9 Saturday, 17 November 12
  21. APPLICATION ARCHITECTURE SHOWCASE • We need a profile system to

    hold user data. ⽤用户帐户系统。 • The profile system will potentially be used standalone. ⽤用户帐户系统未来可能会被独⽴立使⽤用。 • We need plugin-able “modules”. 需可插⼊入式模块系统。 • There will potentially be 3rd party modules. 未来可能会有第三⽅方开发的模块。 9 Saturday, 17 November 12
  22. APPLICATION ARCHITECTURE SHOWCASE • We need a profile system to

    hold user data. ⽤用户帐户系统。 • The profile system will potentially be used standalone. ⽤用户帐户系统未来可能会被独⽴立使⽤用。 • We need plugin-able “modules”. 需可插⼊入式模块系统。 • There will potentially be 3rd party modules. 未来可能会有第三⽅方开发的模块。 • Of course, the development timeline is tight. 开发周期很紧凑。 9 Saturday, 17 November 12
  23. PERFECT? NO! • Longer development time. 开发周期过⻓长。 • Can’t guarantee

    the usefulness of the API layer for 3rd party developers. 不可预知 API 层在未来是否还可有效利⽤用。 11 Saturday, 17 November 12
  24. PERFECT? NO! • Longer development time. 开发周期过⻓长。 • Can’t guarantee

    the usefulness of the API layer for 3rd party developers. 不可预知 API 层在未来是否还可有效利⽤用。 • More complexity == more chances to screw up. 系统越复杂,越容易出错。 11 Saturday, 17 November 12
  25. EASY, BUT FOR HOW LONG? • One app is more

    difficult to scale out. 单⼀一系统相对较难向外扩展。 13 Saturday, 17 November 12
  26. EASY, BUT FOR HOW LONG? • One app is more

    difficult to scale out. 单⼀一系统相对较难向外扩展。 • It is also more difficult to assign tasks. 单⼀一系统相对较难安排团队成员任务。 13 Saturday, 17 November 12
  27. EASY, BUT FOR HOW LONG? • One app is more

    difficult to scale out. 单⼀一系统相对较难向外扩展。 • It is also more difficult to assign tasks. 单⼀一系统相对较难安排团队成员任务。 • It is more likely to have leaky code. 单⼀一系统相对更难有效封装。 13 Saturday, 17 November 12
  28. A BALANCED SOLUTION IS A GOOD SOLUTION • Don’t over-engineer.

    避免过度⼯工程。 15 Saturday, 17 November 12
  29. A BALANCED SOLUTION IS A GOOD SOLUTION • Don’t over-engineer.

    避免过度⼯工程。 • Good degree of separation of concern. 注重关注点分离。 15 Saturday, 17 November 12
  30. A BALANCED SOLUTION IS A GOOD SOLUTION • Don’t over-engineer.

    避免过度⼯工程。 • Good degree of separation of concern. 注重关注点分离。 • Internal interfaces are easier than external APIs: 内部接⼝口相对外部 API 更易开发: ‣ @gateway ||= PlatformModuleGateway.new(args) ‣ mod = module_controller(module_name).new(args) ‣ mod.validate_input ‣ mod.render_view 15 Saturday, 17 November 12
  31. Single responsibility 单⼀一责任 Open/close 开闭 Liskov substitution ⾥里⽒氏替换 Interface segregation

    接⼝口分离 Dependency inversion 依赖倒置 21 Saturday, 17 November 12
  32. Passes all the tests. Contains no duplication. Expresses the intent.

    Minimises the number of classes and methods. 23 Saturday, 17 November 12
  33. CONTRIBUTE TO OPEN SOURCE PROJECTS • Reading code is just

    as important as writing code. 阅读代码与编写代码同重要。 26 Saturday, 17 November 12
  34. CONTRIBUTE TO OPEN SOURCE PROJECTS • Reading code is just

    as important as writing code. 阅读代码与编写代码同重要。 • Learn from the masters. 向⼤大师们学习。 26 Saturday, 17 November 12
  35. CONTRIBUTE TO OPEN SOURCE PROJECTS • Reading code is just

    as important as writing code. 阅读代码与编写代码同重要。 • Learn from the masters. 向⼤大师们学习。 • Take some, give some - sharing is awesome. 不断收获的同时,别忘了付出。 26 Saturday, 17 November 12
  36. CONTRIBUTE TO OPEN SOURCE PROJECTS • Reading code is just

    as important as writing code. 阅读代码与编写代码同重要。 • Learn from the masters. 向⼤大师们学习。 • Take some, give some - sharing is awesome. 不断收获的同时,别忘了付出。 • Make things more useful for yourself therefore for others too. 对⾃自⼰己有⽤用的东⻄西,也许对他⼈人也有⽤用。 26 Saturday, 17 November 12
  37. CONTRIBUTE TO OPEN SOURCE PROJECTS PHP CodeIgniter PHP Kohana PHP

    Vanilla Forums PHP Yii Framework JAVASCRIPT AutoSuggest RUBY Ruby on Rails RUBY RailsConfig RUBY Slim RUBY ORM Adapter RUBY Delayed Job RUBY Parallel Tests 27 Saturday, 17 November 12
  38. OPEN SOURCE YOUR OWN WORK • Made something useful? Release

    it! 写了有⽤用的好玩意⼉儿?发布吧,勇敢的少年! 28 Saturday, 17 November 12
  39. OPEN SOURCE YOUR OWN WORK • Made something useful? Release

    it! 写了有⽤用的好玩意⼉儿?发布吧,勇敢的少年! • Be critisied of your work, and learn from mistakes. 虚⼼心接受意⻅见与批评,由错误中学习。 28 Saturday, 17 November 12
  40. OPEN SOURCE YOUR OWN WORK • Made something useful? Release

    it! 写了有⽤用的好玩意⼉儿?发布吧,勇敢的少年! • Be critisied of your work, and learn from mistakes. 虚⼼心接受意⻅见与批评,由错误中学习。 • Be proud of your work, and be recognised. 为⾃自⼰己的⾟辛苦成果感到⾃自豪。 28 Saturday, 17 November 12
  41. OPEN SOURCE YOUR OWN WORK • Made something useful? Release

    it! 写了有⽤用的好玩意⼉儿?发布吧,勇敢的少年! • Be critisied of your work, and learn from mistakes. 虚⼼心接受意⻅见与批评,由错误中学习。 • Be proud of your work, and be recognised. 为⾃自⼰己的⾟辛苦成果感到⾃自豪。 • Make a little dent in the universe. ⼀一点⼩小⼩小的贡献的话,可以哟〜~ 28 Saturday, 17 November 12
  42. OPEN SOURCE YOUR OWN WORK RUBY Action Throttler Throttle actions

    based on configurable duration and limit. RUBY Angel Nest An open source 'clone' of AngelList. RUBY API Taster Visually test your Rails application's API. RUBY AppReset Resets (and if available, seeds) your databases. RUBY Bustle Activities recording and retrieving using a simple Pub/Sub-like interface. RUBY Datamappify Turn ActiveRecord into DataMapper (sort of)! RUBY Haml2Slim Convert Haml templates to Slim templates. RUBY Inherited Resources Views DRY your view files! RUBY Ruby Decorators Ruby method decorators inspired by Python. RUBY Security Guard A collection of useful tools for auditing data. RUBY Slim Bundle A Textmate / Sublime Text bundle for Slim. PHP Authlite A lightweight, flexible Auth module for Kohana. PHP KThrottler Throttle actions based on configurable duration and limit. PHP PHamlP A bridge between Kohana and PHamlP. JAVASCRIPT Endless Scroll Endless / infinite scrolling solution for jQuery. JAVASCRIPT Inline Confirmation Less obtrusive confirmation dialogues. JAVASCRIPT Skinny Coffee Machine A simple state machine with observers. JAVASCRIPT Slideshow Lite A lightweight slideshow plugin for jQuery. 29 Saturday, 17 November 12
  43. DO FREELANCE WORK • Like open source work, but with

    deadlines and pressure. 截⽌止期限与压⼒力。 49 Saturday, 17 November 12
  44. DO FREELANCE WORK • Like open source work, but with

    deadlines and pressure. 截⽌止期限与压⼒力。 • Like open source work, but with some $$$. 赚点外快。 49 Saturday, 17 November 12
  45. DO FREELANCE WORK • Like open source work, but with

    deadlines and pressure. 截⽌止期限与压⼒力。 • Like open source work, but with some $$$. 赚点外快。 • Be involved in projects different to those at your day job. 不同的项⺫⽬目体验与经验。 49 Saturday, 17 November 12
  46. DO FREELANCE WORK • Like open source work, but with

    deadlines and pressure. 截⽌止期限与压⼒力。 • Like open source work, but with some $$$. 赚点外快。 • Be involved in projects different to those at your day job. 不同的项⺫⽬目体验与经验。 • Communication skills with your clients. 客户沟通经验。 49 Saturday, 17 November 12
  47. DO FREELANCE WORK • Like open source work, but with

    deadlines and pressure. 截⽌止期限与压⼒力。 • Like open source work, but with some $$$. 赚点外快。 • Be involved in projects different to those at your day job. 不同的项⺫⽬目体验与经验。 • Communication skills with your clients. 客户沟通经验。 • Communication skills with your remote team members. 远程团队沟通经验。 49 Saturday, 17 November 12
  48. AND LASTLY, YOUR DAY JOB • You spend most of

    your hours awake at your day job, make it count! 50 Saturday, 17 November 12
  49. AND LASTLY, YOUR DAY JOB • You spend most of

    your hours awake at your day job, make it count! • Know what you are looking for. 知道⾃自⼰己想要什么。 50 Saturday, 17 November 12
  50. AND LASTLY, YOUR DAY JOB • You spend most of

    your hours awake at your day job, make it count! • Know what you are looking for. 知道⾃自⼰己想要什么。 • What can you get out of working at the company? 在这家公司⼯工作,能学习到什么? 50 Saturday, 17 November 12
  51. AND LASTLY, YOUR DAY JOB • You spend most of

    your hours awake at your day job, make it count! • Know what you are looking for. 知道⾃自⼰己想要什么。 • What can you get out of working at the company? 在这家公司⼯工作,能学习到什么? • What did you get out of working at the company? 在这家公司⼯工作,学习到了什么? 50 Saturday, 17 November 12
  52. PERSONAL BRANDING • Designers have online portfolios, what about us

    developers? • Blog - show me your thoughts! 51 Saturday, 17 November 12
  53. PERSONAL BRANDING • Designers have online portfolios, what about us

    developers? • Blog - show me your thoughts! • Twitter/Weibo - show me your passion! 51 Saturday, 17 November 12
  54. PERSONAL BRANDING • Designers have online portfolios, what about us

    developers? • Blog - show me your thoughts! • Twitter/Weibo - show me your passion! • GitHub - show me your code! 51 Saturday, 17 November 12
  55. PERSONAL BRANDING • Designers have online portfolios, what about us

    developers? • Blog - show me your thoughts! • Twitter/Weibo - show me your passion! • GitHub - show me your code! • LinkedIn - show me your resume! 51 Saturday, 17 November 12
  56. PERSONAL BRANDING • Build up your network 拓展交际圈 • Establish

    your reputation 树⽴立好名声 • People will endorse your work 让更多⼈人赞誉你的成果 52 Saturday, 17 November 12
  57. “I get paid for code that works, not for tests,

    so my philosophy is to test as little as possible to reach a given level of confidence.” -- Kent Beck 69 Saturday, 17 November 12
  58. EFFECTIVE TESTS • They are describing ActiveRecord behaviours. • Allow

    mass assignments on foreign keys is wrong. 70 Saturday, 17 November 12
  59. EFFECTIVE TESTS • They are describing ActiveRecord behaviours. • Allow

    mass assignments on foreign keys is wrong. • They are testing how methods are implemented. 70 Saturday, 17 November 12
  60. EFFECTIVE TESTS • They are describing ActiveRecord behaviours. • Allow

    mass assignments on foreign keys is wrong. • They are testing how methods are implemented. • No confidence gained. 70 Saturday, 17 November 12
  61. PROBLEM • A user has many trips • Each trip

    may contain more than one stops, e.g. • Beijing -> Shanghai • Shanghai -> Hongkong 78 Saturday, 17 November 12
  62. PROBLEM • A user has many trips • Each trip

    may contain more than one stops, e.g. • Beijing -> Shanghai • Shanghai -> Hongkong • We only want to display the first stop from each trip 78 Saturday, 17 November 12
  63. This portion of the slide is intentionally left blank. One

    function?! 100 Saturday, 17 November 12