Comment first coding
Comment first coding is a technique that I have used for many many years, but only today found out it has an actual name! (I had a jolly good Google before starting writing this post).
I find it especially useful when I am coding in a language which I am not overly familiar with.
The basic premise of Comment first coding, is planning out what you want your code to do using either plain English, pseudo-code or a mixture of both, in comments.
Then going through one comment at a time, actually writing the code proper.
//db-jointeam.php - POST(team ID), find playerID from username ($_SESSIONS variable)
// If playerID = specified Team's ownerID
// Add player to teamlobbyplayers
// Set isActive to 1
// Else
// If isActive = 1
// Add player to teamlobbyplayers
// Else
// Error, lobby not active
// Endif
// Endif
Above is an example of some Comment first coding from a project I am working on which uses PHP to access a MySQL Database which holds the games player and team data.
Conclusion
And that’s pretty much all there is to Comment first coding. Like I said earlier, I find this technique to be extremely helpful generally, but more so when I’m using a language which I’m not overly familiar with.