PHP is well-documented. It is forgiving at first but can be ratched up in strictness. My knowledge of the language gained me my first serious employment and began my software engineering career, and this last point has secured it a place in my heart where it will never be dislodged, if admittedly in an Iron Man sort of way.
But baby, why?
<?php class Animal { static $dbTable = "animals"; function printDbTable() { echo(self::$dbTable); } } class Bear extends Animal { static $dbTable = "bears"; } $bear = new Bear(); $bear->printDbTable(); # prints "animals" ?>
This has somewhat stymied a reasonably hefty piece of refactoring of this very site's backend, which I had hoped to do this weekend. I was hoping to make it so that the name of the table where a particular class of object, such as a Page or a Comment, is stored, could be reconfigured just by altering a static variable in each class. Unfortunately the Row superclass's retrieve() method, which would need to grab that static variable in order to query the database correctly, can't. It just can't. At all. Oh, and get_class() has the same issue. There is get_called_class(), which is only in 5.3.0 plus. I'm on 5.2.0. I should ask my host to upgrade, perhaps. Or find a programming language which isn't broken.
Just another of the whacking great heap of enraging programming fun which I've ploughed through so far this week. Most of you know I've been hitting the JavaScript quite hard, and most of you will probably therefore not need to be told why that has irked me of late. Here's another which springs to mind, this time a piece of code by someone else which I had to refactor slightly. This is Perl, but the programming language is basically irrelevant because the problem is universal and eternal. Why would anybody write this:
for(my $i = 0; $i < 10; $i++) { # code if( [condition1] ) { # maybe 200 lines of double indented code if( [condition2] ) { # hundreds more lines of triple-indented code # etc., maybe to two more levels of indentation # and the first loop was probably indented a bit already anyway } # no code at all down here } # or here }
When something like:
for my $i (0..9) { # code next unless [condition1]; # 200 lines of code next unless [condition2]; # hundreds more lines }
is entirely acceptable? If you're about to say "coding standards", the script in question plainly predates such things. Maybe the original coder is from Single Point Of Exit land. I'm not. Perl has these lovely keywords for a reason. This can be done in almost every other language too, if a little less beautifully.
One more minor riddle which wasn't worth a distinct post. Every few weeks, seemingly at random times and triggered by nothing whatsoever, Notepad would open on my laptop. The problem was so rare and intermittent that I never bothered to look it up. The reason? Dell's touchpad drivers have an additional "feature" which opens Notepad if you hold down three fingers on the pad for more than one second.
This feature is completely absent from the mouse/touchpad settings. I know this having been over every detail of the available options when I first acquired the machine in question. It cannot be configured or disabled. The only way one could possibly know that the feature was there was if you first investigated the specific touchpad driver, discovered that it had been manufactured by Synaptic, and then stumbled onto this page which actually documents this baffling, inexplicable feature.
Meanwhile there are people running around out there who think that they have a virus of some kind! They're running virus scans and upgrading their firewalls. The worst part is how difficult it is to figure out how to reproduce. Whoever even heard of a touchpad which did anything when three fingers were applied? This may be the very first thing I've seen which behaves so much like a bug and yet genuinely is not a bug, but an undocumented feature.
Discussion (18)
2010-05-08 00:46:59 by DTal:
2010-05-08 01:50:56 by Paul:
2010-05-08 03:15:11 by JeremyBowers:
2010-05-08 03:33:42 by Ross:
2010-05-08 06:41:12 by Lar:
2010-05-08 09:57:01 by Baughn:
2010-05-08 17:54:18 by Brent:
2010-05-08 18:07:34 by Baughn:
2010-05-08 21:52:22 by qntm:
2010-05-09 00:10:26 by Baughn:
2010-05-13 21:33:04 by DanKuck:
2010-05-13 23:08:21 by qntm:
2010-05-19 02:37:39 by JohnM:
2010-05-19 02:38:34 by JohnM:
2010-05-26 00:57:42 by Mike:
2010-06-07 16:30:16 by Cory:
2010-06-20 22:51:25 by sapphirecat:
2015-10-29 13:48:43 by Resuna: