Jump to the navigation menu

Simpler code doesn't mean less code

Just because I consider some code to be simpler, that doesn't necessarily mean there's less code.

It's possible to write a whole function or class on one line, but that doesn't mean it's simple to read or understand.

The opposite is also true.

I can extract business logic from Controller classes into different service classes, commands or actions.

I can use data transfer objects (DTOs), value objects and Collection classes to give names and meanings to things instead of always using generic strings, arrays or objects.

I can follow design patterns and implement Repositories, Decorators, Factories and Builders to better organise code and make it easier to use and update.

I can write tests that act as examples and executable documentation for people to see how to use the code I've written.

This can all make code easier to read, understand and use - even though there is more of it.

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an certified Drupal Triple Expert with 18 years of experience, a Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.