Samir Talwar – Four Rules of Simple Design –> Higher-Order Functions

Summary

I want to demonstrate how object-oriented principles can only get you so far in simplifying your design.

Starting with a clean yet completely imperative code base written in Java, I will explain how we can improve the code by applying functional principles—primarily extracting functions as objects and passing them around.

Along the way, I will be pointing out how each refactor simplifies the code according to one or more of the four rules.

We will start by removing duplication, even where duplication isn’t apparent from an OO point of view, before making the code clearer by replacing the language of the system by the language of our domain. Along the way, we’ll reduce the number of moving parts and increase test coverage.

I will also show existing libraries in Java and C# that can help you refactor your own code to be smaller and more understandable.

This is a live coding presentation. There will be no* slides, just lots of refactoring on a projector. You will not need any understanding of functional programming in order to attend.

* There may be some slides. We’ll see.

Duration

60 min

Detailed schedule

00–10: The four rules of simple design

10–15: Explanation of the goals

15–50: Coding

50–60: Slack

Questions throughout.

What will you learn?

What the four rules mean

How to read and write functional code

How to remove boilerplate duplication (if, for, while, switch, etc.)

How to write code that expresses your ideas, rather than the steps required to achieve them

Prerequisites

The ability to read Java

The wish to have your mind blown

What’s next?

Take a look at domain-driven design

Learn a functional programming language

Write cleaner, smaller, more understandable code!

Do the attendees need a laptop?

No, unless they wish to follow along. I will put together instructions for setting up an identical starting environment.