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

Global Day of CodeRetreat 2018

Global Day of CodeRetreat 2018

In joint cooperation with Vlado Kopso

Jakub Fojtl

November 17, 2018
Tweet

More Decks by Jakub Fojtl

Other Decks in Programming

Transcript

  1. Introduce yourself name, rank, service number What’s your name? What’s

    your project/company? What’s your programming language of choice?
  2. What is CodeRetreat Honing the craft togetherTM Have a day

    to have fun coding like you always wanted to Make tests important in your life Leaving you comfort zone Knowledge transfer – while listening to others Your code is not your baby!
  3. Agenda 5x 45min sessions Programming in pairs Every new session

    add a new constraint After each session, code is deleted Retrospective after each ‘sprint’
  4. Craftsmanship A violinist practices two hours a day… Know your

    tools Practice solving interesting problems Be part of the community Not only working, but well-crafted software http://manifesto.softwarecraftsmanship.org/
  5. “You can call it beautiful code when the code also

    makes it look like the language was made for the problem” Ward Cunningham quoted in “Clean Code” by Bob Martin.
  6. 4 rules of simple design “I'm sorry I wrote you

    such a long letter; I didn't have time to write a short one.” Blaise Pascal Passes the tests Reveals intention No duplication Fewest elements
  7. Pair programming TDD Ping-pong Person A only writes tests (test

    code only) Person B only tries to get the tests to pass (production code only) Both persons refactor when appropriate Navigator-Pilot Person A designs algorithms, tests (usually on paper), performs on-the-fly code review Person B writes the actual code Especially suitable when the pair is uneven in coding ability But, the more able coder can assume any of the roles! Regular Ping-pong Person A only writes ~ 4 lines of code Person B only writes ~ 4 lines of code Repeat…Refactor
  8. Conway’s Game of Life A zero-player game invented by John

    Horton Conway in 1970 A cellular automaton Evolution depends only on initial state, no user input required afterwards Our today’s an anchor problem Well defined Simple, yet interesting Easy to solve in small scales, yet difficult for large ones Many implementations exist, vastly more are possible
  9. Universe of Conway’s Game of Life infinite two-dimensional orthogonal grid

    of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent. Transitions are discrete – occur in ticks
  10. 4 rules of Game of Life Only four in total

    Any live cell with fewer than two live neighbors dies as if caused by under-population Any live cell with two or three live neighbors lives on to the next generation. Any live cell with more than three live neighbors dies as if by over-population Any dead cell with exactly three live neighbors becomes a live cell as if by reproduction.
  11. Any live cell with fewer than two live neighbors dies:

    as if caused by under-population Any live cell with two or three live neighbors lives on to the next generation. Any live cell with more than three live neighbors dies: as if by over-population Any dead cell with exactly three live neighbors becomes a live cell: as if by reproduction
  12. 1st iteration On your marks... 3… 2... 1… Go! Find

    your pair partner According to your language of choice Free-Style Just try to solve the problem as you see fit Get to know the rules of Life What about the infinity problem? How to name things? Don’t have to write tests!
  13. Test-driven development Tests clear out your intentions to others Tests

    make you understand the problem more Tests make for great acceptance criteria Tests will save your time – no only in the end Fast code verification: no need to run whole module/product to debug Tests will make you a braver coder “TDD is not dead or alive. TDD is subject to tradeoffs, including risk of API changes, skill of practitioner and existing design” Kent Beck.
  14. Write tests while case is hot Aka the developer mood

    lifecycle mood time Day 1: I love designing and coding stuff Day 2: Still good, posting for review Day 3-4: I have to make it ‘work’ until Demo! Damn! Unit tests… L
  15. 2nd iteration TDD, TDD, bla bla bla Write the test

    first Write minimal code that makes it pass Refactor Repeat
  16. 3rd iteration No naked primitives No primitives You have to

    encapsulate the: Arrays, Integer, String, Boolean As class/type for every data structure Bonus: - all functions under 4 LOC - all classes under 20 LOC
  17. 4th iteration What was that polymorphism thing? No conditionals (IF-THEN-ELSE

    | SWITCH-CASE) statements. No loops (FOR, WHILE) No ternary operator No GOTO statement ;)
  18. 5th iteration game of life as a service Write the

    GOL algorithm so that it is encapsulated in a docker container Start, next iteration as a REST API call Ideally, start a microservice for each living cell (and dispose of it as it dies)
  19. Retrospective Have you learned anything new today? What was it?

    Have you been surprised by anything? What was it? What will you do differently after today?