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

Software Craftsmanship

Software Craftsmanship

A talk I did for about 200 Unit4 developers on june 6th about software craftsmanship and how we do that at Kabisa.

Note: I'm available for talks.

Ariejan de Vroom

June 06, 2012
Tweet

More Decks by Ariejan de Vroom

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. Ugly Code is... •... hard to maintain •... even harder

    to debug •... impossible to change •... it does not make you happy
  4. Workflow •Write one test. •See that test fail. •Write the

    most simple solution to make the tests pass. •Refactor.