Hi, I'm Lukas Atkinson. My irregularly published long form blog posts cover topics such as software development, testing and quality assurance, or programming language concepts and whatever I currently find interesting. Learn more about me, or take a look at my projects.

Recent Posts

Simpler Tests thanks to “Extract Method” Refactoring

by Lukas Atkinson

I'm currently refactoring a huge method into smaller parts. It is stock full of nested loops, maintains a complex state machine with more variables than I have fingers, and is the kind of code where I have to ask myself how I could ever think this would have been a good idea. So obviously, I'm splitting that function into smaller, independent chunks with the Extract Method refactoring technique. Since the control flow is now simplified, the code has also become easier to test – as long as I'm comfortable with testing private methods. Why?

The number of test cases needed for full path coverage corresponds directly to the McCabe complexity of the code under test. Since many simple functions often have lower total complexity than one convoluted function, the overall required testing effort is reduced. As this reduction can be substantial, there is a strong incentive to test the extracted methods directly, instead of testing only through the public interface.

read full post (7 min)

Reasonable Code

If it's impossible to follow, that code is bad.

by Lukas Atkinson

What is reasonable code? In an article on The Whiteboard, a fellow software developer under the pen name “Jimmy Hoffa” thinks about reasonability as a measure of code quality. He arrives at six exemplary properties of reasonable code:

  • small scope
  • short stacks
  • explicit data use
  • explicit data ownership
  • explicit outputs
  • dictating instead of deciding

He makes a good case for continuous self-​improvement and a focus on code quality in our development process. It is well worth the read, especially for beginning professionals. And not quite by chance, it seems to be a subtle advertisement for functional programming and static typing: anything else would have a hard time meeting his characteristics of reasonable code.

read external article (5 min)

Good API Documentation

by Lukas Atkinson

This post provides suggestions on writing good API documentation that targets programmers: how you can document a class, library, or command line utility so that other programmers or power users can make good use of it. Not covered is documentation for end users or GUIs, although some ideas would certainly translate.

read full post (12 min)

MOPping it up

Building a simple Metaobject-Protocol

by Lukas Atkinson

Many languages make a distinction between objects and classes. But shouldn't everything – including classes – be an object in a pure object-oriented language? Some languages like Smalltalk, Common Lisp, and Ruby manage just that and offer a complete and flexible Metaobject-Protocol. Others such as Java only offer a read-only object protocol commonly called “introspection” or “reflection”.

In this post, I'll explore how to create a simple Metaobject-Protocol where classes are objects – all without creating infinite loops. We'll be using a previous post's JavaScript object encoding as a basis for this MOP.

read full post (18 min)

Emerging Objects

Building a simple object system out of closures

by Lukas Atkinson

Object-oriented programming and functional programming imply each other. While encoding closures as objects is a well-known technique (see the command pattern, and e.g. Functors in C++), using closures to implement objects is a bit more unusual.

In this post, I will explore creating a simple object system in JavaScript, using only the functional parts.

read full post (10 min)

That's all for now. Subscribe to the RSS feed to get notified as soon as my next post gets published.