Don't dump. Write a test.

How often do you use functions like var_dump, dump, dd or console.log to debug an issue?

You want to check the type or value of something, so you add the debug code and reload the page.

If you don't resolve it on the first attempt, you change it or add more debugging lines which, hopefully, you'll remember to clean up before committing your code.

This is a time-consuming process, especially if the code you're debugging isn't easy to trigger.

Maybe it only happens when you've submitted a long form, so you need to manually complete the form each time you want to debug it, if certain steps have already happened or the application state is a certain way.

Instead, consider writing an automated test.

They can be run when needed without needing to manually fill in forms or complete complex steps, and become a permanent part of the codebase rather than something that's only added temporarily whilst debugging.

They can be run manually by Developers, automatically in a CI pipeline and serve as documentation and examples.

Don't dump. Test.

P.S. If you want to learn how to write automated tests in Drupal, subscribe to my free 10-day email course.