Facebook PHP source code from August 2007

Every line of code I write has a comment above it. The reason is because I write the comments first as a form of pseudo code. This forces me to figure out the entire logic of a method in advance. I usually do it within the scope of a single method but sometimes I'll do it for an entire class. So I'll have, for example, 10 comments in a method that describe every planned imperative line of code. I then write each line below the applicable comment. Usually when all is said and done the comments become useless once the code is written but I leave them in there because it explains my thought process at the time the code was written, which comes in handy sometimes. It's an experiment I've been doing in production for a few years now on our framework and libraries - the coworkers originally thought I was nuts until they watched me do it real-time. They now usually direct all the juniors to my code base when they need help understanding something. It's best used when I'm writing framework or library code - it's too verbose and time consuming for RAD or day-to-day client stuff. The primary benefit is it drastically reduces logic related bugs because I'm forcing myself to think through the entire logic of the applicable scope before a single line of code is written - so by the time the code is written the logic will have been analyzed at least twice. It's not for everybody and most people reading this probably think it's crazy, but I don't mind being the black sheep. In light of the human experience, programming is still in its infancy - there's still many techniques undiscovered. This technique works for me when I'm writing code aimed at extremely high reusability. Hate me. I don't give a damn.

/r/PHP Thread Parent Link - gist.github.com