An impression of myself

And now, my impression of myself at every meeting I've ever attended, in haiku form:

Check your phone check it
check it check it check it now
Maybe somethings new

The difference between perl backticks, system and exec

If you have to execute a system call using perl, there are three ways to do it. Two of them are synchronous and your perl script will pause until the system call is executed completely.

Be careful in your selection. If you choose backticks or system( ), your script will not continue execution until the process call is complete. If that process takes too long, and this is a CGI process, the calling script could timeout, and return a 504 error to your browser.

exec

This call executes a command and doesn't return. This, effectively, kills your script.

system

This call executes a command, and the calling script will wait for the command to execute before continuing. However, you can work around this by backgrounding the process:

system("perl some_process.pl &");


backticks

This call executes a command, then waits for the STDOUT output of the command, before continuing.


The autistic developer

It seems to me that developers are far more stubborn than any other phyllum of worker I have known. Not only do they get set in their ways, they get wedged in their ways so tightly and so inextricably, that any attempt to dislodge them will end in disaster.

Example: just try to get a developer - who writes his functions in camelcase - to write his functions in all lower case. So, instead of writing

function myFunction(){

you require that he writes:

function my_function(){

Try and tell a programmer to make that kind of a life-altering change, and then sit back. If you've never seen the Exorcist, you're about to see it now. You're about to see heads spinning 360 degrees and pea soup flying in every direction.

As a consequence of outbursts like these, developers get an awful rap. They are resistant to change. They're surly. They're arrogant. They have massive egos. But it's not really true. Few developers have big egos. Rather, they have fragile egos, if they have egos at all. The typical developer doesn't think massively of himself. He can barely make eye contact.

And therein lies the root of the problem. Developers are, for the most part, not arrogant and egotistic. Developers, for the most part, aren't even geeky nerds with low social skills.

Developers are, for the most part, autistic. The world of programming is a honeypot, attracting Aspies like they were flies.

Keep that in mind the next time you are about to launch into a tirade with some junior developer who floutes convention puts his braces on their own line.

Enough with the controversy

Enough with the endless controversy over braces. Same line or their own line – who cares. Why have we become such a fractured and polarized community over this? We aren't the Capulets and the Montagues. And this is not Sophie's choice.

Evil Guard: I will let you escape the concentration camps, but you must first choose between placing your opening braces on a new line, or on the same line as the function or conditional.
Sophie: Can't I do both as they suit me?
Evil Guard: No.

The difference between unit and functional tests

I do it all the time.

I call everything a unit test, when it really isn't. I can't help it. I've been conditioned because I use a tool called phpUnit to run our automated testing. As a consequence, I refer to Functional tests as Unit tests. But it's important to understand the differences.

Unit tests

  • each test tests one little thing in isolation from everything else,
  • Usually a test for a small method,
  • dependencies are faked, stubbed or mocked - there is no actual database connection,
  • they run very quickly,
  • these should be the vast majority of your tests,
  • they should be built as you developer (TDD)

Functional tests

  • these are high level tests,
  • they test the integration of the system with other parts,
  • they have dependencies (ie. database, other services, filesystem, etc),
  • run much slower than unit tests,
  • these should be at a bare minimum,
  • they are best built to duplicate a test that would be run by a QA analyst
  • they should be built using something like Selenium
  • they should be run separately from the unit test suite
Mixing Unit and Functional tests in same test class is risky. It means that your setup and teardown, which might include loading of fixtures, runs with every single test, including the unit tests. If this is over enough test classes, you'll find that your test suite will quickly get to the point where no one is running the tests locally, because they take too long.
To sum up:

  1. Keep your unit and functional tests separate
  2. Never connect to the database with a unit test
  3. Always run your unit tests before a commit (they should be very fast)
  4. Build your functional tests to be front end tests, mocked with Selenium or something similar
  5. Run your functional tests as part of the QA regression suite

Guess the browser


Brace yourself: there's an argument coming


I am now resident in an insane asylym where the coding standard is to have every brace on its own line.

I'm a great believer in In House coding standards, especially anal coding standards, because they serve a valuable purpose: they give us a weapon with which to whip the juniors. But sometimes, things go a little too far. Like our enforced coding standards:

Instead of:

if ($x) { doX();}
else{ doY();}

you must write:

if ( $x )
{
   doX();
}
else
{
   doY();
}

This, I am told, increases readability, carrying the direct implication that the former decreases readability. This is like asserting that raising corporate taxes will cause economic ruin. It sounds right, but it's never been put to the test. Likewise, I have yet to see any evidence that one brace convention is more readable.

Really, are we all children? If we don't see the braces on their own line, do we panic and spill our coffee over the keyboard? Has either one been the source of bugs in any program?

Manager: You've been working at your desk nonstop 16 hours. What's going on?
You: I'm trying to debug this program, but there are too many braces on the same line. I keep getting confused.
Manager: Deep breaths. Take deep breaths.
You: But it gets worse! There are all these braces that are on their own line. I don't understand why they are there.
Manager: A program with braces on the same line as the function AND braces on their own line. (picks up phone) Ted, you better wake up the President.

The real reason we have these arguments isn't based in rationality. There is no correct answer. The real reason we have these arguments is that most coders are autistic to some degree. Putting function braces on their own line is more than just a preference for them. It's how they live their lives.

In the same way that the Rain Man absolutely had to watch Judge Wapner every day, developers absolutely have to code in the specifically prescribed manner.

The soul search of riding the bus

I can't get it right. If someone sits beside me on the bus, it pisses me off that they have encroached on my personal space, and I steadfastly refuse to close my knees .

But if they walk past me, I take personal offense. I've tried smiling, I've tried looking them in the eye as they walk down the aisle. Or I'll studiously look away. It doesn't matter. They don't sit beside me. Which I realize is a good thing. But it's a bit of a shot to the self esteem.

Google tells us that it's a good thing to have only Google

Remember when Ask Jeeves, Lycos, and countless other search engines were all muscling against each other for the right to tell us where everthing was? No one realized it was a battle to death, and they were fighting over who could best predict what mankind wanted.

No one ever thought that having alternative search engines was particularly useful. We know this, because we've googled it and Google tells us that we only want one search engine.

Big Broogle

Does it make anyone else uncomfortable that Google has spent the better part of 20 years perfecting the ability to guess what everyone is thinking about?