I'm trying to make my code easily understood by future readers.
I've always had issues with how to word my if statement comments to make it the most understandable.
Maybe it seems trivial, but it's something that's always bothered me
Here's an example:
if ( !$request ) {
$request = $_SERVER['REQUEST_URI'];
}
Here are some way I can think of commenting it
// If request doesn't exist
if ( !$request ) {
// Set request to current request_uri
$request = $_SERVER['REQUEST_URI'];
}
// Check for a request
if ( !$request ) {
$request = $_SERVER['REQUEST_URI'];
}
// Request doesn't exist
if ( !$request ) {
// Set request
$request = $_SERVER['REQUEST_URI'];
}
Not the best example, but the way I see it there are infinite ways to word it.
I've never really worked on a team so I don't have much experience on other people reading my code.
What are your experiences on the best way to word that to make it readable for future coders.