Make the right things easy
It's not a new concept: doing the right thing should be easy, doing the wrong thing should be hard. In blogs, books, or management guides that's the advice you get for preventing people from doing the wrong thing. In practice, this is a subtle science and I believe this little apothegm needs some tweaking. My recommendation is "Make doing the right things easy enough that the doing the wrong things is embarrassing."
What's the difference?
In practice, making the wrong things hard can of itself be hard. Often the wrong thing is an established practice or convention. It may be the only way some people know how to get things done. Even worse, it may just be easy. When you're faced with this kind of ill luck, you need to look at the problem from a different angle. Making the right things easy becomes a cultural endeavor.
The subtle part
It starts with the leadership. Messaging from the leadership has a direct impact on the goals and priorities of the engineering workforce. If engineers know that taking longer to do the right thing is encouraged, then there is a much higher likelihood they will take that path than if that encouragement is absent. Leadership can reinforce the message by rewarding the engineers who go above and beyond to do the recognized right thing in challenging situations. They can sponsor development of tools that will make doing the right things easier.
All of this will *encourage* good behavior, but it won't do too much to discourage bad behavior.
For every encouragement there is an equal and opposite discouragement
It's important to me to be clear about what I mean when I say "embarrass." I do not mean that leadership or any team member should explicitly embarrass another team member. A culture that publicly shames or embarrasses its team is caustic, foments fear, and dampers collaboration . You don't want that kind of culture, but you don't want to hide the bad stuff either. My suggestion is that the trick is in believing in good intentions.
Unless your hiring process is extremely dysfunctional, you should be able to assume your engineers have good intentions. That means that by encouraging the desired behavior, people will naturally be discouraged from doing otherwise. As your tools and processes continue to make the encouraged behaviors easier, it will become increasingly difficult to justify doing the wrong things.
An example of this is using leader boards to send a message. Consider a situation in which you want to encourage your engineers to write more unit tests. First, you invest in making writing tests *really* easy. Then, you start tracking unit test code coverage per commit. Soon thereafter, you can publish a leader board of "person to % code coverage per commit." You won't be explicitly calling anyone out for habitually not adding providing reasonable code coverage, but it will be clear over time that certain individuals may not be doing so .
I hope this opens up a healthy discussion about how we can stop complaining about bad behaviors and start feasibly changing them today.
 See Leaders East Last by Simon Sinek for a great exposition of this.
 Note I don't believe in metrics that track raw quantity. I don't feel that such measures accurately capture the intention. Metrics that people can be proud of should track the quality of their work over time, not "gamable" counts that are easily subverted.