Comment On Loose Cat Handling

"I had a pretty good idea of what I was getting into," Christian Riesen wrote, "the company I started at was very forthcoming about their codebase, and how it had grown organically over the past 12 years. I took the job because it would be a challenge to convert it from single files with tons of includes to a to a framework-based approach." [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Loose Cat Handling

2012-06-11 10:10 • by Gandor (unregistered)
I prefer languages, which will let you shoot yourself in the foot if you want to.

The problem is, that PHP is too easy to use. Maintaining such a mess after someone, that have "somehow" written the app is mind blowing...

Re: Loose Cat Handling

2012-06-11 10:14 • by the beholder (unregistered)
And I always thought curiosity killed the $cat, when it actually was just pointing to another variable.

Re: Loose Cat Handling

2012-06-11 10:16 • by GWO (unregistered)
Well, you see, PHP utilises the latest Quantum Computing technologies, so the $cat variable can exist in a superposition of the scalar and array states.

Re: Loose Cat Handling

2012-06-11 10:17 • by Code Slave
I suppose

svn blame <file>

would do nothing but removed plausible deniability as to why the previous programmer's body parts has been stapled to bulletin board in the coffee room.

Re: Loose Cat Handling

2012-06-11 10:17 • by pjt33
It's like http://forums.thedailywtf.com/forums/t/26141.aspx optimised to compress the WTF into (almost) the smallest possible code.

Re: Loose Cat Handling

2012-06-11 10:18 • by Kasper (unregistered)
382943 in reply to 382939
the beholder:
I always thought curiosity killed the $cat
Curiosity was framed, ignorance killed the cat.

Re: Loose Cat Handling

2012-06-11 10:21 • by PleegWat (unregistered)
382944 in reply to 382941
Code Slave:
I suppose

svn blame <file>

would do nothing but removed plausible deniability as to why the previous programmer's body parts has been stapled to bulletin board in the coffee room.


svn: command not found

Re: Loose Cat Handling

2012-06-11 10:28 • by Kaine (unregistered)
382945 in reply to 382943
But satisfaction brought 'em back!

Re: Loose Cat Handling

2012-06-11 10:30 • by MightyM (unregistered)
382946 in reply to 382939
the beholder:
And I always thought curiosity killed the $cat, when it actually was just pointing to another variable.


So it's Schrödinger's $cat?

Re: Loose Cat Handling

2012-06-11 10:31 • by MightyM (unregistered)
382947 in reply to 382940
GWO:
Well, you see, PHP utilises the latest Quantum Computing technologies, so the $cat variable can exist in a superposition of the scalar and array states.


So it's Schrödinger's $cat?

(Quoted the wrong post before)

Re: Loose Cat Handling

2012-06-11 10:38 • by Scrummy
The less strongly-typed the language, the more important good unit testing is. This is a cornerstone of Agile development.

Re: Loose Cat Handling

2012-06-11 10:57 • by Anon (unregistered)
382950 in reply to 382947
MightyM:
GWO:
Well, you see, PHP utilises the latest Quantum Computing technologies, so the $cat variable can exist in a superposition of the scalar and array states.


So it's Schrödinger's $cat?

(Quoted the wrong post before)


Re: Loose Cat Handling

2012-06-11 10:59 • by $$ERR:get_name_fail (unregistered)
382951 in reply to 382947
MightyM:
So it's Schrödinger's $cat?

You mean $schroedinger->cat?

Re: Loose Cat Handling

2012-06-11 11:01 • by Charles (unregistered)
382952 in reply to 382938
Gandor:
I prefer languages, which will let you shoot yourself in the foot if you want to.


Having the power to shoot yourself in the foot by choice is one thing. A well-designed language, though, will make sure it's by choice -- in Clojure, for instance, if I want to mutate a variable (unsafe) rather than temporarily rebinding it (safe), I have to use a function with a with a ! on the end of its name, which marks it as "do this only if you're paying attention" -- and the scoping rules are very, *very* clear and explicit.

PHP, on the other hand... well, have you read the "fractal of bad design" essay?

Re: Loose Cat Handling

2012-06-11 11:03 • by Recursive Reclusive (unregistered)
382954 in reply to 382949
Scrummy:
The less strongly-typed the language, the more important good unit testing is. This is a cornerstone of Agile development.

Does that have any relevance to the story?

Bug or Feature?

2012-06-11 11:05 • by Doug (unregistered)
What I want to know is if the reduction of $cat to a single entry is a necessary and intended effect or an unintended consequence. After a couple of years working there will you automatically recognize and use this pattern? I have at least one pattern I use repeatedly that has provoked amazement and revulsion in the uninitiated, but is too useful to give up.

Re: Bug or Feature?

2012-06-11 11:10 • by ntroutman
382956 in reply to 382955
Doug:
[...] I have at least one pattern I use repeatedly that has provoked amazement and revulsion in the uninitiated, but is too useful to give up.

I might regret this, but I have to know; what is it?

Re: Bug or Feature?

2012-06-11 11:17 • by TheSHEEEP (unregistered)
382958 in reply to 382956
ntroutman:
Doug:
[...] I have at least one pattern I use repeatedly that has provoked amazement and revulsion in the uninitiated, but is too useful to give up.

I might regret this, but I have to know; what is it?


Code documentation.

Re: Bug or Feature?

2012-06-11 11:23 • by Geoff (unregistered)
382959 in reply to 382955
Right, I was wondering if this was 'clever programing' or a pure bug as well.

Re: Loose Cat Handling

2012-06-11 11:30 • by Tobias Rohde (unregistered)
I expected that it loops only once and $cat is the first element of the array $cat.

Maybe the code is prehistoric (PHP 3 and older). The function array_pop was implemented in PHP 4.

Re: Loose Cat Handling

2012-06-11 11:56 • by dogmatic (unregistered)
File this WTF under '$catalogical'

Re: Loose Cat Handling

2012-06-11 11:59 • by barf 4eva (unregistered)
382962 in reply to 382940
hahah! awesome answer!

Re: Loose Cat Handling

2012-06-11 12:14 • by myName (unregistered)
"And to make matters worse: it actually works"

in that case the real WTF is complaining about it.

Re: Loose Cat Handling

2012-06-11 12:22 • by Mason Wheeler
382964 in reply to 382945
Kaine:
But satisfaction brought 'em back!


What if you can't get no satisfaction?

Re: Loose Cat Handling

2012-06-11 12:41 • by Jazz (unregistered)
In before everyone insists, without any rational reason or documentation, that PHP is a horrible mutant shitpile that deserves to be ridiculed, belittled, and exterminated.

(Maybe I've been reading TDWTF too long, but I'm kind of jaded on how PHP is the designated punching bag for languages around here.)

Re: Loose Cat Handling

2012-06-11 12:50 • by KattMan
382967 in reply to 382966
Jazz:
In before everyone insists, without any rational reason or documentation, that PHP is a horrible mutant shitpile that deserves to be ridiculed, belittled, and exterminated.

(Maybe I've been reading TDWTF too long, but I'm kind of jaded on how PHP is the designated punching bag for languages around here.)


Nope, you haven't been here long enough because the designated punching bag is VB (either 6 or .net it doesn't seem to matter, though if somethignh is still in VB6 I would agree with them anyway)

Re: Loose Cat Handling

2012-06-11 12:52 • by Coyne
It's quite simple to understand, m'kay? $cat is in scope outside the loop, and $cat is a local variable in scope only within the loop.

Got that?

Re: Loose Cat Handling

2012-06-11 12:56 • by operagost
I prefer comments, that don't use superfluous commas, to ones that do, because the latter, are difficult to read.

Re: Loose Cat Handling

2012-06-11 13:08 • by Leo (unregistered)
382970 in reply to 382966
Jazz:
In before everyone insists, without any rational reason or documentation, that PHP is a horrible mutant shitpile that deserves to be ridiculed, belittled, and exterminated.


...but it is. Anyone who likes PHP is by definition a terrible developer.

Re: Loose Cat Handling

2012-06-11 13:46 • by BR (unregistered)
382973 in reply to 382970
Leo:
...but it is. Anyone who likes PHP is by definition a terrible developer.


So half of the front-end developers at Facebook then?

Re: Loose Cat Handling

2012-06-11 13:52 • by sfs (unregistered)
382974 in reply to 382940
GWO:
Well, you see, PHP utilises the latest Quantum Computing technologies, so the $cat variable can exist in a superposition of the scalar and array states.


Ah, but when you measure the state of the wave-variable, you end up with either the scalar or the array state.

Thus leading to the Heisenbug uncertainty principle. Loosely stated, this means "you're screwed."

Re: Loose Cat Handling

2012-06-11 13:54 • by M (unregistered)
382975 in reply to 382973
BR:
Leo:
...but it is. Anyone who likes PHP is by definition a terrible developer.


So half of the front-end developers at Facebook then?


Only half?

Re: Loose Cat Handling

2012-06-11 13:55 • by sfs (unregistered)
382976 in reply to 382938
Gandor:
I prefer languages, which will let you shoot yourself in the foot if you want to.

The problem is, that PHP is too easy to use. Maintaining such a mess after someone, that have "somehow" written the app is mind blowing...

...right, because we all know that C++ programs have far fewer bugs than PHP programs...

Re: Loose Cat Handling

2012-06-11 14:00 • by DescentJS
382977 in reply to 382976
sfs:
Gandor:
I prefer languages, which will let you shoot yourself in the foot if you want to.

The problem is, that PHP is too easy to use. Maintaining such a mess after someone, that have "somehow" written the app is mind blowing...

...right, because we all know that C++ programs have far fewer bugs than PHP programs...

Because, of course, there's no language other than C++ that he could have possibly meant. No other languages allow you to shoot yourself in the foot, No sir.

Re: Loose Cat Handling

2012-06-11 14:01 • by frits
Shit code is shit.

Re: Loose Cat Handling

2012-06-11 14:01 • by sfs (unregistered)
382979 in reply to 382963
myName:
"And to make matters worse: it actually works"

in that case the real WTF is complaining about it.


Until you have a feature request where you have to modify it, and this breaks a lot of stuff, causing hours or days of debugging.

Brittle code tends to shatter when touched.

Re: Loose Cat Handling

2012-06-11 14:09 • by sfs (unregistered)
382980 in reply to 382977
DescentJS:
sfs:
Gandor:
I prefer languages, which will let you shoot yourself in the foot if you want to.

The problem is, that PHP is too easy to use. Maintaining such a mess after someone, that have "somehow" written the app is mind blowing...

...right, because we all know that C++ programs have far fewer bugs than PHP programs...

Because, of course, there's no language other than C++ that he could have possibly meant. No other languages allow you to shoot yourself in the foot, No sir.

The OP selected a class of languages: not easy, let you shoot yourself in the foot. I drew a language (C++) from that class to illustrate that the OP's point did not make a ton of sense.

Feel free to select your own language from that class and see if compares more favorably. I bet it won't. Incidentally, there aren't a lot of commonly-used, modern languages that fit in this class anymore. C++ is one of the better known ones.

Re: Loose Cat Handling

2012-06-11 14:09 • by dogmatic (unregistered)
382981 in reply to 382973
BR:
Leo:
...but it is. Anyone who likes PHP is by definition a terrible developer.


So half of the front-end developers at Facebook then?


Having worked quite a bit with the FB API and php I would say yes, most if not all the devs at Facebook are pretty terrible.

The one thing I can say for php, at least it isn't javascript. Now with html5 web devs are expected to make full scale web apps using js, a language that doesn't support file includes and object orientation only through a whole lot of syntactic sugar. And it has to run on many platforms with different implementations of js. Now QA and debugging time has multiplied by an order of 10. Makes me long for the days of Flash and Actionscript... say what you want about Flash, but at least AS3 is a real language and runs relatively the same across platforms. And furthermore, say what you want about the tenets of national socialism, dude, at least it's an ethos!

Re: Loose Cat Handling

2012-06-11 14:20 • by flyboyfred (unregistered)
382982 in reply to 382969
operagost:
I prefer comments, that don't use superfluous commas, to ones that do, because the latter, are difficult to read.


Indeed. Commas, which are misplaced, can actually change the meaning of the sentence.

Re: Loose Cat Handling

2012-06-11 14:32 • by Jack (unregistered)
382983 in reply to 382969
operagost:
I prefer comments, that don't use superfluous commas, to ones that do, because the latter, are difficult to read.

I prefer comments that have something to do with the story. Oops...

Re: Loose Cat Handling

2012-06-11 14:32 • by Mike (unregistered)
Maybe the $cat has nine lives?

Re: Loose Cat Handling

2012-06-11 14:35 • by uns (unregistered)
Had to test this. It really works as advertised.

$ cat a.php
<?php

$a[] = "abc";
$a[] = "def";

var_dump($a);

foreach ($a as $a) {
echo "Element of a: $a\n";
}

var_dump($a);

?>
$ php a.php
array(2) {
[0]=>
string(3) "abc"
[1]=>
string(3) "def"
}
Element of a: abc
Element of a: def
string(3) "def"
$

Re: Loose Cat Handling

2012-06-11 14:52 • by Vlad Patryshev (unregistered)
Creative, but not as bad as the author thinks. Changing the projection, so to say.

Re: Loose Cat Handling

2012-06-11 14:53 • by Jay (unregistered)
The problem is that there are languages that give you the flexibility to make programs that are efficient and that do a wide variety of tasks, and there are languages that make it hard for you to shoot yourself in the foot. But the overlap between the two is very small.

Like: C: If it's possible to do it on the computer, you can probably do it with C. But you can hurt easily hurt yourself with a moment of carelessness. It's a high-speed powertool language.

COBOL: If it involves reading a file with fixed-length fields and printing a report, you may be able to do it with COBOL. But it's very difficult to hurt yourself. It's a child's plastic hammer language.

Re: Loose Cat Handling

2012-06-11 14:55 • by Jay (unregistered)
The policeman pulls Heisenberg over. "Do you know how fast you were going?" he demands.

"Honestly officer, I don't," Heisenberg answers. "But I know exactly where I am!"

Re: Loose Cat Handling

2012-06-11 14:57 • by henke37
Foreach isn't quite as simple one would think in php, try explaining this one:
http://pastebin.com/m4fmWCPD

Re: Loose Cat Handling

2012-06-11 15:00 • by Nagesh (unregistered)
382990 in reply to 382987
Jay:
If it's possible to do it on the computer, you can probably do it with C.


This ain't being entirely corect. Yes, true for major OS and some embeded system, but RTOS with most often be runing diferent, special system. it is great massage to be able to have compiler for almost all hardwares using C.

Re: Loose Cat Handling

2012-06-11 15:01 • by I don't get it. (unregistered)
Is the submitter saying the loop works internally, but after that $cat is just the last element in the array? Seems like a twofer then.

Re: Loose Cat Handling

2012-06-11 15:01 • by Peppitoz (unregistered)
You want buy cat?

Cat Very Fresh, Picked this morning.
1 Cat 50 MSK, Cat 75 MSK.





CAT NOT FOR SALE, good day sir.

Re: Loose Cat Handling

2012-06-11 15:15 • by foo (unregistered)
382994 in reply to 382966
Jazz:
In before everyone insists, without any rational reason or documentation, that PHP is a horrible mutant shitpile that deserves to be ridiculed, belittled, and exterminated.
s/before/after/;s/without/with/
(see 382952 and read the essay it mentions)
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment