Sign in to your account



This field is required


forgot your password?


New to the site? Create an account →

Oct 24th, 2013 at 10:10:16 am

tcr! · Oct 24, 2013 at 10:10 am

This kind of code drives me nuts…

if (!($log->HasDownloaded())) {
	// do stuff
} else {
	// do other stuff
}

Just take out the extra characters to make it more legible at first glance and flip the conditional code…

if ($log->HasDownloaded()) {
	// do other stuff
} else {
	// do stuff
}

This is even better, no question what’s happening or when…

if ($log->has_downloaded() === TRUE)
{
	// do other stuff
}
else
{
	// do stuff
}

Yes, somebody else will skim your code in the future.

#devhell

Add a comment

It’d be better if you signed in before commenting


Post



Latest articles for #devhell

Jun 6th, 2019 at 11:47:17 am

Jun 6th, 2019 at 11:47:17 am

Jun 6, 2019 at 11:47 am

The function/method MUST return the number of bytes written.Why? I’m…

Developer laments, a Cobain quote, and more!

Developer laments, a Cobain quote, and more!

Jan 10, 2019 at 12:46 pm

Being a dork web developer who: loves code is forced to use WordPress…

Phone number optionally required

Phone number optionally required

Dec 1, 2018 at 12:05 pm

Good one Google. 🙄 #devhell #google

Aug 20th, 2018 at 3:16:17 pm

Aug 20th, 2018 at 3:16:17 pm

Aug 20, 2018 at 3:16 pm

Writing a valid, functional, and strict MySQL regular expression for…