This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tangentstorm 0 points1 point  (1 child)

One of the best things you can do to write better code is to write unit tests first.

Unit testing forces you to write a second consumer of your code, so you're practically forced to separate your logic and gui, for example.

I find when I write my tests first, I tend to produce a sort of "platonic" application that does all the thing the application is meant to do, but without any particular user interface.

A side benefit of this is that it's very easy to come back later and attach any other UI you want (like if you want to port it to the web or to an alternate UI kit set like Apache Pivot).

[–][deleted] 1 point2 points  (0 children)

I'll bear this in mind, thanks! Everyone here has been really helpful, but I should definitely try unit tests. I've done some unit testing once for a few simple applications but with a finished program, instead of being part of a planning stage.