Paul M. Jones

Don't listen to the crowd, they say "jump."

Regarding Underscores

Today, PHPDeveloper.org referred to a post by Leszek Stachowski about underscore prefixes on non-public class elements.

The question which comes instantly to my mind is: why? Is there any reason why this convention should be kept when PHP object oriented programming has gone a long way since PHP 4 (when there was no access modifiers and such underscore was the only fast way to distinguish public from, hmm, not public methods and properties) ? Are, for instance (as one of major OOP languages), Java coding standards pushing towards such naming convention? No!

I think that we, as developers, should not stick to this silly convention. For the sake of progress, stop looking back (because that what in fact this convention is) and stop supporting this one, particular naming convention.

I think the underscore-prefix for protected and private is a good convention to keep. As with many things about programming, this convention is not for the program, it is for for the programmer. For example, limiting your line length to about 80 characters is a good idea, not for reasons of “tradition”, but because of cognitive limitations of human beings who have to read code.

Likewise, using the underscore prefix is an immediate and continuous reminder that some portions of the code are not public. Its purpose is as an aid to the programmer. The underscores make it obvious which parts of the program are internal, and which parts are externally available. (Note that I do not extend this argument to support the use of Hungarian Notation in PHP; if something like the underscore prefix is overused, it loses its obvious-ness and thus becomes less powerful.)

As an example, look at the following code:

<?php
class NoUnderscores
{
    protected $data = array(
        'item' => 'magic-data',
    );

    protected $item = 'property-value';

    public function __get($key)
    {
        return $this->data[$key];
    }

    protected function doSomething()
    {
        // do we want the magic public item,
        // or the internal protected item?
        return $this->item;
    }
}

Here we have magic __get() method that reads from the protected $data property. Any time you try to access a property that doesn’t exist, PHP will go to the __get() method and read from protected $data. Now look in the doSomething() method. Because the code executes inside the class, it has access ot the protected $item, so it’s not obvious if the programmer wanted the value of protected $item, or the magic $data['item'].

By way of comparison, take a look at the following modification to use the underscore prefix on private and protected elements:

<?php
class Underscores
{
    protected $_data = array(
        'item' => 'magic-data',
    );

    protected $_item = 'property-value';

    public function __get($key)
    {
        return $this->_data[$key];
    }

    protected function _doSomething()
    {
        // it is clear we want the internal protected item
        return $this->_item;
    }
}

Now the _doSomething() method is perfectly clear: the programmer wants the value of the internal protected property.


How Stalin and Hitler enabled each other’s crimes

Comparing the Soviet Union to the Nazis only makes the Nazis look better if you don’t understand the truth about the Soviet Union. Communists are as bad as Nazis, and communist sympathizers and apologists are as bad as Nazi sympathizers and apologists.

via Instapundit » Blog Archive » HOW STALIN AND HITLER enabled each other’s crimes. A review of Timothy Snyder’s Bloodlands: Europe ….

And from the review itself:

The Soviet Union’s ethnic murders predated Nazi Germany’s. Stalin was not directly responsible for the Holocaust, but his pact with the Nazis paved the way for Hitler’s killing of Jews in the east.

via Mass murder: History and its woes | The Economist.


Starbucks Puts Quality Over Quantity

What Starbucks would really like is simply to be able to say "make a latte this way every single time", and have thousands of baristas hop to." But anyone who has ever managed employees knows that this isn't quite so easy as it sounds. Even with the cleverest and most motivated employees, little changes will creep in over time; when I was a canvass field manager for PIRG, I was always a little astonished to find the varied ways that people had modified the standard "rap" they were supposed to give at each door, often without even realizing that they'd gone off script. This is why Atul Gawande is so gung-ho on making doctors hew to checklists and hard-to-modify standardized procedures.

via Starbucks Puts Quality Over Quantity - Megan McArdle - Business - The Atlantic.


Mystery and Evidence

... Christianity rests upon certain historical claims, like the claim of the resurrection. But this is not enough to make scientific hypotheses central to Christianity, any more than it makes such hypotheses central to history. It is true, as I have just said, that Christianity does place certain historical events at the heart of their conception of the world, and to that extent, one cannot be a Christian unless one believes that these events happened. Speaking for myself, it is because I reject the factual basis of the central Christian doctrines that I consider myself an atheist. But I do not reject these claims because I think they are bad hypotheses in the scientific sense. Not all factual claims are scientific hypotheses. So I disagree with Richard Dawkins when he says “religions make existence claims, and this means scientific claims.”

...

Religion, on the other hand, attempts to make sense of the world by seeing a kind of meaning or significance in things. This kind of significance does not need laws or generalizations, but just the sense that the everyday world we experience is not all there is, and that behind it all is the mystery of God’s presence. The believer is already convinced that God is present in everything, even if they cannot explain this or support it with evidence. But it makes sense of their life by suffusing it with meaning. This is the attitude (seeing God in everything) expressed in George Herbert’s poem, “The Elixir.” Equipped with this attitude, even the most miserable tasks can come to have value: "Who sweeps a room as for Thy laws/ Makes that and th’ action fine."

...

Religions do make factual and historical claims, and if these claims are false, then the religions fail. But this dependence on fact does not make religious claims anything like hypotheses in the scientific sense. Hypotheses are not central. Rather, what is central is the commitment to the meaningfulness (and therefore the mystery) of the world.

All emphasis mine. Via Mystery and Evidence - NYTimes.com.

Update, 06 Oct: For what it's worth, I consider myself an agnostic.



The Problem Is *Spending*, Not Taxes

What’s the difference between a tax-cut stimulus and a spending stimulus? Some efficiency, sure, less rent-seeking and pork-barreling, no doubt. But if we cut taxes without cutting spending, we are not cutting taxes. We are deferring taxes. Taxes are not the problem; spending is the problem. Taxes are a symptom.

via Bobs-for-Jobs Schilling: Another Republican for Keynesian Stimulus - By Kevin D. Williamson - Exchequer - National Review Online.


Government and journalists cower at threats to cartoonist

Last week, the Seattle Weekly announced that Molly Norris, its editorial cartoonist, had "gone ghost." Put another way, she went into hiding. The FBI told her she had to because otherwise it couldn't protect her against death threats from Muslims she'd angered. Earlier this year, Norris started "Everybody Draw Mohammed Day" to protest radical Muslims' violently stifling freedom of speech and conscience. Incredibly, her plight has drawn precious little media attention, even though it is infinitely more newsworthy than, say, a fundamentalist preacher in Florida threatening to burn Qurans.

via Examiner Editorial: Government and journalists cower at threats to cartoonist | Washington Examiner.


Finding What You're Looking For

One of the things I find most wearying about writing about economics is the extent to which people attempt to hijack economics to "scientifically prove" that their value judgements about things like the proper size and role of government are 100% factually correct--as if there were some way to empirically validate the correct marginal tax rate for people making over $100,000 a year.

But even when you're careful, it's distressingly easy to find what you expect. The result is a history of science developing models that used "scientific evidence" to bolster the social hierarchy of the day. We think that phrenology and 19th century racialism are obviously preposterous--but they clearly weren't, because some very smart people believed them, and were not conscious that they were simply confirming their own prejudices.

via Finding What You're Looking For - Megan McArdle - Technology - The Atlantic.


Mao's Great Leap Forward 'killed 45 million in four years'

The only people I hate worse than Nazis are the God-damned Communists.

during the time that Mao was enforcing the Great Leap Forward in 1958, in an effort to catch up with the economy of the Western world, he was responsible for overseeing "one of the worst catastrophes the world has ever known".

Mr Dikötter, who has been studying Chinese rural history from 1958 to 1962, when the nation was facing a famine, compared the systematic torture, brutality, starvation and killing of Chinese peasants to the Second World War in its magnitude. At least 45 million people were worked, starved or beaten to death in China over these four years; the worldwide death toll of the Second World War was 55 million.

via Mao's Great Leap Forward 'killed 45 million in four years' - News, Books - The Independent.


The voice of reason vs. the voice of insanity

Geithner wants to re-create the system that collapsed but with “tighter regulations.” He wants to re-create the system that the CBO expects to cost taxpayers $390 billion. He wants to re-create the system that helped destroy the housing market and the financial sector.

Oh, and he wants high fees on banks and borrowers to protect the taxpayer. So he ants a government guarantee to keep rates low at the same time there’d be a fee to make sure the system isn’t too fiscally irresponsible. Madness.

via The voice of reason vs. the voice of insanity.