Integrated Tests Are a Scam

Found this gem in a tweet from @david_whitney, and as he says the title is trolly but none the less is an excellent talk on automated testing.

Integrations Tests Lead to Bad Design

  • An interesting point is made (and I am paraphrasing) that the more integration tests we have the less design feedback we get, leading to sloppy design as we don’t feel the same feedback & design pressure…

What Failed and Where?

  • Integration tests may highlight failures, and the name of the test may go a long way to saying what failed, but pin pointing the actual location and reason for the failure is often lost in the generalization of the test itself.

The Systemic Growth of Integration Tests

“…[they’re] like taking aspirin that make your headache worse…”

  • Given 3 components which each interact with each other, how many tests would we need to cover all code paths?
Component # Paths
A 3
B 5
C 7

3 x 5 x 7 = 105 Integration Tests*

  • Add a 4th subsystem, as a result of a refactoring, with 2 paths removed from C moved into Component D:
Component # Paths
A 3
B 5
C 5
D 2

3 x 5 x 5 x 2 = 150 Integration Tests*

*At Least as to cover all code paths.

  • This is an example of negative design pressure, specifically in this instance to refactoring, which itself is important to obtaining good design.
  • Resulting in another 45 tests being created and a on going cost of the time it will take to execute these tests.
  • Not to mention the time it takes to run these tests hardly lends itself to a rapid Red Green Refactor cycle that would be possible with more isolated tests.

The Solution

  • Design to Contracts — If each Component operates against a contract, and the interactions between each component are clearly identified through design then come implementation we will be able isolate and ensure each component behaves correctly given the contract is upheld on both ends.

  • Tests Subsystems in isolation — Isolation can be achieved through the use of Test Doubles or Mocks, to ensure each interaction with other components follow the contract under each of the specified scenarios.

The talk goes into much more detail and is crammed with practical advice… GO WATCH and make the world a better place.

HTTP Status Code Decision Diagram

The best HTTP Status Code decision diagram I have seen to date. Source: https://raw.githubusercontent.com/for-GET/http-decision-diagram/master/httpdd.png

Devlog: Ruby Bits 1 & 2

Completed the RUBY BITS courses on CodeSchool. Again… I was impressed with the content, as a casual rubyist I got plenty out of doing this.

I really enjoyed this course, I took away a lot of useful idioms which I will put to good use (when I get the chance).

The meta-programming a DSL creation in RUBY BITS part 2 were great… adding methods to classes dynamically is pretty bad-ass for drying up code.

I always wanted default method implementation on interfaces in C#, dunno why I brought this up other than in Ruby that would never ever be an issue with the features you have at your disposal… very few languages lead to as much developer happiness.

Just one of those languages I would love to write everyday if I could. Moving onto Rails Testing for zombies course next…

…that said Elixir has hit v1.x and the Dave Thomas “Programming Elixir” book has been released, so that will most likely eat up the next month or two of my life.

Tunes: Mesterházy - Körzeti Varázslóhivatal (2002)

Tunes: Minimal Mondays | 04 | Hooked On

My IDM binge continues….

Devlog: Real Time Web With Node.js

Completed the Real Time Web with Node.js course on CodeSchool

Another impeccable course, produced to the usual high standards which I have come to expect with each and every CodeSchool module. Go give these guys money and do a few courses, worth every penny.

I have completed a couple of node.js projects to date and am currently working on a biggin’, so I didn’t find this course very challenging, but I did find it fun, another great jingle and lots of great content.

The examples go a long way to show how much you can do with so little code, walking students through using socket.io and redis to build a chat client and a Q&A system.

Something I learned was how to use redis effectively, the course got me started and provided useful tips such as limiting size of a list to 10 items for example:

1
2
3
4
5
6
7
8
9
var redis = require("redis"),
    client = redis.createClient();
//... on last meeting submitted ...
var meeting = JSON.stringify(lastMeeting)

// Use LPUSH & LTRIM in tandem
client.lpush('recent_meetings', meeting, function(err, reply) {
  client.ltrim('recent_meetings', 0, 9) // 10 Items Max
})

and for good measure, using my new CoffeeScript skills, the same thing:

1
2
3
4
5
6
7
redis = require("redis")
client = redis.createClient()
#... on last meeting submitted ...
meeting = JSON.stringify lastMeeting

client.lpush 'recent_meetings', meeting, (err, reply) ->
  client.ltrim('recent_meetings', 0, 9) # 10 Items Max

P.S. This gif of Eric Allam & Gregg Pollack cracks me up no end…

Devlog: A Sip of CoffeeScript

Completed the CoffeeScript course on CodeSchool.

I love these list comprehensions… I don’t think I will be writing straight JS for a while.

1
2
3
4
5
6
7
8
9
10
# Eat lunch.
eat food for food in ['toast', 'cheese', 'wine']

# Fine five course dining.
courses = ['greens', 'caviar', 'truffles', 'roast', 'cake']
menu i + 1, dish for dish, i in courses

# Health conscious meal.
foods = ['broccoli', 'spinach', 'chocolate']
eat food for food in foods when food isnt 'chocolate'

Refactoring Ruby With Monads

A plain & simple, practical and short introduction to monads and how they can be put to add some elegance to your code!

Do yourself a favour and take 30 mins to add some very slick refactoring tricks into your toolbelt.

Devlog: What I’ve Been Learning

These last few months I have been learning more than usual and in this post I talk a little about some of the things that have caught my interest. All of this is outside of work as my day job is working on a Trading platform written in C#.

Another goal of this post is to kick start my blogging again which I have completely got out of the way of doing over the last 2 or so years.

Erlang & Elixir

Partially inspired by my functional programming binge and a chat I had with Joe Armstrong at ReactConf; I have been getting stuck into Erlang, Elixir and the Phoenix web framework.

I feel these will play a big part in my future. The BEAM VM is fascinating and the powerful distributed programming model via the OTP libraries is something different and interesting. I look forward to digging into these topics on my blog in the coming months as I become more familiar with them.

I am working on an ‘anonymous’ location broadcast server to use these technologies in anger and I have found this has helped me achieve those A-HA moments that are so important when it comes to learning something and making it stick.

Node.js

I’ve been working away on a personal project (which will be launched at outloud.io some time in the future) using node.js, express.js, postgreSQL, passport.js, mocha, chai, chai-as-promised, Q, db-migrate, node-env…

I have had this idea for a while, and I got pretty excited about building it. At the time I was looking for a good excuse to get stuck into a substantial project which was built on node.js. Even though I have used JS for years I have learned a great deal about the node way, building stuff tis the best way to learn it is no secret.

Ruby and Rails

I completed a MOOC course on Coursera on Web Application Architectures which used Ruby & Rails recently. Was very much entry level stuff, got through it in about 2 days and I think anybody with significant web dev experiences would find the same thing. I guess it showed me that I knew more than I thought about Ruby and Rails and needed to focus on more advanced and newer topics.

I have been slowly but surely learning Ruby for the past 4 years and I find it lots of fun. I used to subscribe and watch the Ruby Tapas episodes which are brilliant, but because I wasn’t using it in my day job for anything more than Chef scripts I never really got to go deep.

Codewars.com stole quite a few of my evenings, a great way to learn or get better using a language by solving a katas (with tests) then seeing how others solved the same problems in a potentially more idiomatic way. Each solution is rated by the community on ‘how smart’ and ‘best practice’ which is a nice touch.

I plan to dig into the latest version of Rails for Zombies on Code School and keep going to the Belfast Ruby meet-ups.

Objective-C

I worked as a “mobile developer” and have built a few apps over the last number of years in various technologies such as Obj-C, Java (Android), C# Xamarin (targeting both iOS and Android) and some PoCs using Phonegap.

But I never felt I got to use Objective-C to the extent I wanted to, as the performance, the sexy runtime dispatch and the CocoaTouch libs intrigued. A friend of mine who now works at Apple once told me the Cocoa libraries were examples of some of the nicest Object Oriented programming he had ever seen. This has always made me want to know more.

My employer sent me on an Objective-C course few months back which was nice of them since I don’t even use it in my current day job.

As I said, apple dev has always interested me so I have read a couple of books and completed numerous little projects.

Right now I am working through the iOS Code School path and building and iOS client for the location broadcast server I spoke about in the Elixir section above.

I wouldn’t mind working on iOS again… which leads me into…

Swift 1.0

XCode 6.0.1 has been dropped and now I have Swift to play with :D. I didn’t have my own Apple dev license so I had to wait. I did pretty much read the iBook cover to cover in the interim.

If I am to ever transition into this area, I would like to do so where I can hit the ground running so I might start to port the Objective-C location client to swift (or maybe just parts of it to get used to the interop).

Data Structure & Algorithms

I always try to keep a balance of new technologies/language and CS theory. Right now I do have a desire to spend more time reading up on Data Structures and Algorithms and their application to big problems. This is the stuff that you learn and is timeless, and there is plenty of it to get stuck into!

I was fortunate enough to do the ‘Writing Concurrent Code with Lock-Free Algorithms’ course by Martin Thompson and I got to hear him speak a couple of weeks ago at the End of Summer Bash event… if you haven’t watched one of his talks please take the time to do so (now).

The big take away for me is the fastest, most elegant and performant solutions, come from using the most appropriate, hand crafted, intelligently selected data structures and algorithms to solve the problem over picking up general purpose tools.

There is so much more in this area that I want to talk about but not in this post… but definitely add Mechanical Sympathy to your blog reader.

Functional & Reactive Programming

I completed the Functional Programming Principles in Scala, a MOOC on Coursera. Before that I completed the Reactive Programming course. These were very good, humbling, challenging and rewarding.

I have been using RX in .NET for years which helped a lot but I still found the Reactive course very worth while. Both these courses use Scala and I enjoyed getting to learn it a bit better. I liked how the reactive programming course built up concepts in layers, starting with getting the students to build a priority queue and finishing with reactive system using the Akka actor model.

Some Books: Remote, Rework & Lean Start-up

In the last 6 months I have read these books each twice (well I used audible so they were read to me twice). Wonderful books which resonated with me on so many levels. They are informative and practical guides which are also quite inspiring.

I think I really got inspired to start developing outloud.io through my desire to just start something of my own from reading The Lean Startup.

Teaching

As a senior engineer I teach as part of my job, but recently I have been helping my buddy who is learning to program.

This is a different challenge altogether, starting from the basics and helping to set the mindset and guide the conceptual thinking required.

He has a degree and a load of music related qualifications and we discussed what would be the best way to start a career in software development.

I have a degree in Computer Science, and I found it very useful, but not necessarily necessary… well depending on the desired job and in a sense that all that theory is accessible elsewhere.

He could go back a do a Masters degree in CS, but is the cost worth it? Maybe… but to get the most out of the year (or 2) having some programming experience would be required before hand and thats where I am helping out.

So, I got to thinking about what are good resources for becoming a programmer and basically ended up recommending the same resources that I use:

  • Coursera & MOOCs
  • Code School
  • Books
  • Podcasts

He has also found some other reasons handy, so I will be sure to link them and his new blog when he gets round to setting it up!

Meteor and DDP

I must say meteor.js and Distributed Data Protocol look very interesting indeed.

Have watched a few screencasts, something that is well and truly on the radar now.

Whats next?

I really need to prioritize thats for sure. This is quite a lot I have going on. It blew my mind when I put it all into Trello… just too much interesting stuff and not enough hours in the day.

Responding in a Timely Manner

Earlier this year I was fortunate enough to attend ReactConf in London, this was one of the sessions. In an earlier post I spoke of how you should should check out Martin Thompson’s videos as they are the proverbial a gold mine of knowledge on building fast and scalable systems.

In this talk Martin defines different levels of “Real Time”, touching on the importance of being responsive and practical tools and advice to achieve that in the real world.

The talk is broken into the following sections:

  1. How to Test and Measure
  2. A little bit of Theory
  3. A little bit of Practice
  4. Common Pitfalls
  5. Useful Algorithms and Techniques

You can find the full conference playlist on youtube here

Enjoy!