You know it's time to 'take 5' when...

Caporegime
Joined
18 Oct 2002
Posts
29,493
Location
Back in East London
You spend 45mins scratching your head at a simple loop that won't stop looping..

Code:
//snippet..
public function getFile ()
{	
	if ((isset($this->files[$this->filesIndex])) !== false) {
		return $this->files[$this->filesIndex];
	} else {
		$this->filesIndex = 0;
		return FALSE;
	}
}
should be..
Code:
public function getFile ()
{	
	if ((isset($this->files[$this->filesIndex])) !== false) {
		return $this->files[$this->filesIndex++];
	} else {
		$this->filesIndex = 0;
		return FALSE;
	}
}

Code:
//use in..

while (($file = $dir->getFile()) !== false) {
//blah..
}
:(

What's your indication that you need to go take a breather?

EDIT: fs.. add one more on my list: 'You have to edit a post 5 or 6 times to get it right..' :(
 
Last edited:
If isset() will only ever return a bool (which it will) why go to the superfluous step of type-checking it against false?

Code:
if ( !isset($this->files[$this->filesIndex]) ) {

is infinitely more readable, and achieves exactly the same as:

Code:
if ((isset($this->files[$this->filesIndex])) !== false) {

I get those funny head-scratching-then-eureka moments too :(
 
Act of habit has me checking types. I'm very 'particular' about my challenges I guess :)

Either it's that or it's because I have one or two that require I check type which has me wanting to make all of them look the same :p
 
robmiller said:
I'm falling in love with ASP.NET I feel really dirty :(
:(

I had a look at it but I have to say I really don't like it, I prefer the way things are done in PHP, it's so much more simple. I really don't like the way ASP.NET tries to emulate an event-driven environment when in reality the only event is the request. All the AJAX, postbacks etc. that get forced down your throught really annoy me :mad:
 
Last edited:
Inquisitor said:
:(

I had a look at it but I have to say I really don't like it, I prefer the way things are done in PHP, it's so much more simple. I really don't like the way ASP.NET tries to emulate an event-driven environment when in reality the only event is the request. All the AJAX really gets to me :mad:

I quite like it, I'm watching the video tutorials and the pros seem to definitely outweigh the cons.
 
Dj_Jestar said:
I'm yet to venture onto it yet.. will be doing so at work hopefully..

I'll likely be using it at my job over summer (if I get it :/) so I'm swotting up now along with SQL Server. I love Microsoft's video tutorials :D
 
Since this is a nit-picking thread...
Inquisitor said:
it's so much more simple
[sic]


And ASP.NET? You dirty thing. Get yourself a decent PHP framework (if that's not an oxymoron) you metro :eek:

/checks out the tutorials :eek: :)
 
I wasn't aware PHP frameworks stopped PHP from being a rubbish language and gave me an IDE as good as Visual Studio... they've certainly come on a bit if they can do that!
 
the only real reason I want to get into it, is because it's almost the most common requirement I am seeing on job-specs :(
 
robmiller said:
I wasn't aware PHP frameworks stopped PHP from being a rubbish language and gave me an IDE as good as Visual Studio... they've certainly come on a bit if they can do that!
Yeah, you got me on the IDE bit. Zend Studio is good but VS is a different world.

Then again, you could argue that PHP is a hobby language and ASP is enterprise class, so meh....

the only real reason I want to get into it, is because it's almost the most common requirement I am seeing on job-specs
Yeah..MS this MS that :(

Actually I prefer anything to Java so that's not such a bad thing I guess :p
 
Back
Top Bottom