I agree with a TDD, but it really depends on the framework&#x2F;cms you&#x27;re working, some of them are incredibly hard to write tests agaist. One of the examples would be writing unit tests for the WordPress plugin, if you&#x27;re sticking to the WordPress way of coding unit testing is practically impossible because there is lot&#x27;s of database access and events which do mess up.<p>You can write plugin folowing OO principles and abstract things out to be able to mock them as nessesery. It really depends on the coding standarts you&#x27;re folowing.<p>As for unit testing. In my personal experience it enforces you to write cleaner code, because when I started I had to do heavy refactoring to be able to test my prototype, but as I wrote more testable code I started separate unrelated parts which reduced amount of spagetti code.<p>Another way to achieve cleaner code in my opinion would be design patters which lets you separate code logically(for example MVC), and make some things cleaner(I&#x27;m big fan of laravel&#x27;s Facades for example).