As with all such freedoms, though, comes room for abuse. This article describes the most common style of code layout. All of them try to make your code easier for yourself and others to read and understand. I won't try to get you to choose any one style over the others. The most important point is that you choose the style that works for you, and stick to it.
Consistency is key.
If you're working on code that someone else has written, the best thing to do is to make your changes using the same style. When you rearrange the layout of working code, you run the risk of inadvertently introducing new errors. The worst thing about these types of errors is that they'll be in unfamiliar parts of the code, not the part you were really modifying, so they'll be difficult to track down and fix. This is my preferred style and is named after Eric Allman, who wrote a lot of the BSD-Unix utilities. I've never come across code written in either of the other two styles.