DEV Community

Cover image for Friction: How Human Behavior Influences Code Development
Willian Ferreira Moya
Willian Ferreira Moya

Posted on

Friction: How Human Behavior Influences Code Development

Introduction

Have you ever tried to start a gym routine, learn a new skill, or start a new side project, and found yourself failing? The reasons for failure can sound familiar:

  • it’s too far away
  • it’s too late to go
  • If only I had this equipment
  • I don’t know how or where to start.

This problem, where obstacles prevent us from starting something new, is known as friction.

Friction in Software Development

What does friction have to do with software development? The answer is everything. Friction can influence the path your team takes in a project.

Imagine you’re trying to encourage your team to add more tests to the existing codebase. However the setup is complex, and the code being tested is large and complicated. This scenario can lead developers to think.

  • “It’s going to be too much work to test this.”

Consequently, laziness sneaks in, and developers start skipping tests or writing fewer, meaningless tests. When your codebase is a mess, it’s harder to reuse things or to look for things to reuse. And without tests, refactoring becomes a big challenge.

Examples of How Friction Can Cause Problems

  1. Testing a Complex Code: If you have to test a code that is messy, hard to understand, and has large methods, it can be exhausting. This can lead you to skip tests or write scenarios that only pass through the code without testing anything.
  2. Frequent Password Changes: If your security team asks you to change your password over and over again, people will get tired of coming up with and remembering new ones. People will start changing their passwords to password1, password2, and so on. And then can lead people to create a passwords.txt file with all the passwords in it (assuming that there’s no easy-to-use password manager available).
  3. Strict Deadlines: A strict deadline can make a developer skip test, avoid best practices, add hard code values in the code, and write hard-to-maintain code.
  4. The pipeline takes too long to execute: Developers can skip tests in the pipeline if they take too long to run and slow down the deployment process.

People, in general, are lazy. If the right is hard, people will follow the easy even when it comes with a cost in the future.

Using Friction in Your Favor

But you can avoid these issues by using friction in your favor, making the right way easy to implement. Here’s how:

  1. Set Up a Quality Gate: You can set up a quality gate and only accept things in the pipeline that match the criteria.
  2. Use Arch Unit: You can use Arch Unit to test your code architecture to make developers respect the code design and keep the best practices. For example, you can set a rule not to use Lombok in your entity objects. If someone breaks this rule, the Arch Unit will break the build.
  3. Leverage Generative AI: You can always use a generative AI to help you create a Java Doc for your writing code.

The idea is simple: make the best practices easy to follow and make it harder to break them.

A Real-Life Example

We had a project that needed a consistent build. The tests took too long to execute and needed to be easier to do. So, some people stopped doing them.

We fixed the tests and made them faster. But after a few months, the same problems came back.

So, I asked a friend to help me with the pipeline. I made the tests faster and easier to create. He set up an alert if someone skipped the tests (this action will be reported), and tweaked Jenkins to make the pipeline run faster.

We made things easier, and faster to reduce friction from the best practices and add friction to the bad practices, by adding a confirmation and report message if the tests were skipped.

Now, no one skips the tests anymore.

So try it out, and think about ways to make the right things easier for your team!

Don’t forget to follow me on social media to be the first to read when my next article comes out!

Willian Moya (@WillianFMoya) / X (twitter.com)

Willian Ferreira Moya | LinkedIn

Follow me here on dev.to!

Top comments (1)

Collapse
 
michaeltharrington profile image
Michael Tharrington

Interesting post, William. Good stuff!