Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Agile Web Applicatie Ontwikkeling Harm de Laat

Slide 3

Slide 3 text

Agile Web Applicatie Ontwikkeling Harm de Laat

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Ariejan de Vroom @ariejan

Slide 6

Slide 6 text

Let’s talk about code!

Slide 7

Slide 7 text

function get_category_by_path( $category_path, $full_match = true, $output = OBJECT ) { ! $category_path = rawurlencode( urldecode( $category_path ) ); ! $category_path = str_replace( '%2F', '/', $category_path ); ! $category_path = str_replace( '%20', ' ', $category_path ); ! $category_paths = '/' . trim( $category_path, '/' ); ! $leaf_path = sanitize_title( basename( $category_paths ) ); ! $category_paths = explode( '/', $category_paths ); ! $full_path = ''; ! foreach ( (array) $category_paths as $pathdir ) ! ! $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir ); ! $categories = get_terms( 'category', array('get' => 'all', 'slug' => $leaf_path) ); ! if ( empty( $categories ) ) ! ! return null; ! foreach ( $categories as $category ) { ! ! $path = '/' . $leaf_path; ! ! $curcategory = $category; ! ! while ( ( $curcategory->parent != 0 ) && ( $curcategory->parent != $curcategory->term_id ) ) { ! ! ! $curcategory = get_term( $curcategory->parent, 'category' ); ! ! ! if ( is_wp_error( $curcategory ) ) ! ! ! ! return $curcategory; ! ! ! $path = '/' . $curcategory->slug . $path; ! ! } ! ! if ( $path == $full_path ) ! ! ! return get_category( $category->term_id, $output ); ! } ! // If full matching is not required, return the first cat that matches the leaf. ! if ( ! $full_match ) ! ! return get_category( $categories[0]->term_id, $output ); ! return null; } — Wordpress

Slide 8

Slide 8 text

class Issue < ActiveRecord::Base def self.search query where("title like :query", :query => "%#{query}%") end def today? Date.today == created_at.to_date end end — Gitlab

Slide 9

Slide 9 text

How do you recognize ugly code?

Slide 10

Slide 10 text

Code Smells

Slide 11

Slide 11 text

•duplicate code •long methods •large classes •too many parameters Code Smells

Slide 12

Slide 12 text

•feature envy •inappropriate intimacy •contrived complexity •über-callback Code Smells

Slide 13

Slide 13 text

Why are you still writing ugly code?

Slide 14

Slide 14 text

Ugly Code is... •... hard to maintain •... even harder to debug •... impossible to change •... it does not make you happy

Slide 15

Slide 15 text

Companies have gone bankrupt because of ugly code.

Slide 16

Slide 16 text

At Kabisa we believe all code should be BEAUTIFUL

Slide 17

Slide 17 text

Find a master to learn from.

Slide 18

Slide 18 text

Master in painting happy little trees. Bob Ross

Slide 19

Slide 19 text

Painting beautiful happy little trees requires practice.

Slide 20

Slide 20 text

Writing clean code requires practice.

Slide 21

Slide 21 text

Code Dojo

Slide 22

Slide 22 text

1. Practice. 2. Get feedback. 3. Throw away your code. 4.Repeat.

Slide 23

Slide 23 text

Hello? Does this work?

Slide 24

Slide 24 text

Test Driven Development vs. Behaviour Driven Development

Slide 25

Slide 25 text

Your tests use your API

Slide 26

Slide 26 text

Your tests define your API

Slide 27

Slide 27 text

Workflow •Write one test. •See that test fail. •Write the most simple solution to make the tests pass. •Refactor.

Slide 28

Slide 28 text

Throw away your code!

Slide 29

Slide 29 text

How do you guys still make money?!

Slide 30

Slide 30 text

Clean Code allows for easy maintenance

Slide 31

Slide 31 text

Clean Code encourages change

Slide 32

Slide 32 text

The test suite proves everything works.

Slide 33

Slide 33 text

We’re learning continuously

Slide 34

Slide 34 text

Happy Developers

Slide 35

Slide 35 text

THANK YOU!

Slide 36

Slide 36 text

http://kabisa.nl [email protected] Ariejan de Vroom @ariejan