REFACTORING MESSY CODE

Creating Highly Configurable Code in Three Simple Steps

Hard-coded, unconfigurable code is headache-inducing

Nicklas Millard
The Startup
Published in
6 min readAug 13, 2020

--

It’s honestly not very difficult to write great, configurable classes. But, it might be if you’ve grown used to doing things in certain ways.

From my experience, the best way to turn an existing class into a configurable one is first to move logic into separate classes and then the moving hardcoded part into constructor or method arguments.

It’s that easy. Let me show you how.

But first, what’s so great about a configurable class?

Before you spend any time refactoring your existing classes into configurable ones, I’ll let you know why it’s so great.

A configurable class is damn easy to use. It’s extensible. It doesn’t do too much. It’s stupid simple, which is awesome.

The biggest selling point, it’s easy to test.

Meet the classes

For good measure, here’s a quick overview of the classes you’re dealing with.

You have an OrderProcessor class with a single method ProcessOrder(Order).

--

--

Nicklas Millard
The Startup

I mostly write to "future me" sharing what I learn and my opinion on software development practices. youtube.com/@nmillard | open for contracts in Jan 2026.