12

That way lies madness

 4 years ago
source link: https://qntm.org/madness
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

That way lies madness

2010-05-07 by qntm

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.


Recommend

  • 24

    You see, when you’re a “normal person” (read: not super smart) and also happen to be a successful software engineer — a lot of people ask you what your deal is. With a degree in Econo...

  • 7
    • treatwell.engineering 4 years ago
    • Cache

    Lies, Damned Lies and Statistics

    Lies, Damned Lies and Statistics

  • 11

    The Future of SEO Lies in the “Messy Middle” of the Purchase JourneyWhat is the "messy middle?" Find out what it is and how SEO professionals' better understanding of this can drive growth in 2021.

  • 6
    • www.swiftjectivec.com 4 years ago
    • Cache

    The Chart That Lies

    The Indie Dev Diaries Presents... The Chart That Lies Written by Jordan Morgan • Jan 24th, 2019...

  • 11
    • rachelbythebay.com 4 years ago
    • Cache

    More lies from Siri

    More lies from Siri Siri lies. Not too long ago, it completely misparsed one of my requests and turned it into a a cheeky encouragement to upgrade the OS on my phone. It looked like this:

  • 7

    Stupidity and lies about point to point networks I've mentioned using /30 assignments for point to point links. It's nothing special, but apparently it was deep magic for whoever set up the links at my school district job. One o...

  • 21

    How to reframe lies about "unlimited" Internet access A recent Hacker News comment inspired me to come up with a way to embarrass Internet providers which claim to have "unlimited" service but actually impose restrictive caps. Ra...

  • 18

    Flash, Lies and Videotape: Broadcast Flash Techniques Pete Barr-Watson, Pixelfury Thursday, July 11, 2002 I was planning on putting up notes on this session, but Pete is showing so much cool stuff that i forgot to take...

  • 13

    Why Quantum Computing's Future Lies in the CloudWhen real-world quantum applications begin appearing, cost, complexity, and other issues will likely float them into the cloud.

  • 6
    • buzzmachine.com 4 years ago
    • Cache

    Dell lies. Dell sucks.

    Dell lies. Dell sucks. June 21, 2005 by Jeff Jarvis Dell lies. Dell sucks : I just got a new Dell laptop and paid a fortu...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK