Development principles, patterns and practices

- from good to great -

Anders J├Ânsson

This presentation will be like:

(We have pieces to eat)

Hopefully it can act as a catalyst for further discussions within the team


  1. Introduction
  2. Pair programming
  3. TDD/BDD
    1. Concepts
    2. Unit/integration/aac tests
  4. TestText
  5. Coding
    1. Patterns and principles
    2. Guidelines
    3. Code sharing
    4. Static code analysis
  6. Continues integration
  7. Wrap up

  8. Ask questions whenever you want



Pair programming

Pair Programming: an idea from the depths of hell that actually works surprisingly well." -- Animesh Karna

Higher quality and more fun

(Research on pair programming, Making Software by Oram & Wilson)



writes the code


keeps track of where we are and where we are heading

You should

  • Switch roles often
  • Stop and reflect on the problem
  • Research
  • Discuss different way of solving the problem
  • Switch pair every day (keep one as story responsible)

You should NOT

  • Pick on the drivers code while writing
  • Grabbing the keyboard from the driver
  • Tweeting, mailing, texting, etc while you are paring

When to pair

Mindset: all the code that goes in to production

Optional to pair on trivial tasks (e.g. updating documentations, batch updates, etc)

It's not so easy, but very fun

Further reading



TDD = Test Driven Development

BDD = Behavior Driven Development

What it is

It's a design process (with the test suite as a bi-product)

What it's not

It's not a process of writing absurd/silly test



* tests

  • Unit tests
  • Integration tests
  • Automated acceptance tests

Enough of that, what can we actually use in our environment?

  1. Automated acceptance tests
  2. Page object pattern

Further reading:



Can be used in environments where TDD/BDD is hard or "impossible"


A simplified example of how it can look like

Before refactoring

LOG: calculate price
LOG: adjust price
LOG: adjust price for VIP
LOG: calculation done	

After refactoring

LOG: calculate price
LOG: adjust price
LOG: calculation done	

Error: missing "LOG: adjust price for VIP"

We must have done something wrong...


What can we do in this environment?


More important than you may think

Establish coding guidelines and follow them

Some guidelines


Patterns and principles

  • Principles
  • Patterns
  • Code smells

The ones we are going to talk about today is just a tip of the...


Separation of Concerns

Is a design principle that comprises the process of separating a computer program into distinct features that overlap in functionality as little as possible

Single Responsibility Principle

States that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class

Feature envy

The whole point of objects is that they are a technique to package data with the processes used on that data. A classic [code] smell is a method that seems more interested in a class other than the one it is in. The most common focus of the envy is the data


Can you find the envy part in this code?

(this example will not work in your environment, but I think you can get the picture)

State pattern

This pattern is used in computer programming to represent the state of an object. This is a clean way for an object to partially change its type at runtime


Before and after

Further reading:


Code sharing (NOT review)

It's about

  • Overall knowledge sharing (about the code and the domain)
  • Learning from each others (coding, design, technologies, etc.)
  • Increase consistency in the code base
  • Point out good things
  • Get a collective code ownership

Static code analysis

Before you commit, you could use tools like jshint and jslint

(available as command line/web gui)

Further reading:


Continues integration

Some of the benefits

  • reduce risks
  • team code cohesion
  • deployable software

On every commit you can

  • Build
  • Run tests
  • Run static code analysis
  • Deploy to a machine
  • Create documentation
  • ...

You can also

  • Create package for production
  • Tag and branch
  • ...

Example of some CI products:


Example of some build languages:


Further reading:


Wrap up

Decide actions

I use this everyday



  • Foundations of Programming (free e-book) by Karl Seguin
  • The Pragmatic Programmer by Andy Hunt
  • Clean Code: A Handbook of Agile Software Craftsmanship by Robert C Martins
  • The Clean Coder: A Code of Conduct for Professional Programmers by Robert C Martins


Thank you for your time!

All images are copyrighted by their respective copyright owners:
  • Pair programming,
  • TDD,
  • Hands tied,
  • Iceberg,
  • Single Responsibility Principle,
  • Separation of Concerns,
  • Static code analysis,
  • Continues integration,
  • Gott & blandat,
  • States,
  • Wrap up (bender),
  • Coding Cup,
  • Questions,