What Is Larry Thinking? #49 => A New Year

January 7, 2012

In this edition…

About This Newsletter

Happy New Year! I hope you are doing well and had pleasant holidays, for those of you that celebrate holidays around this time. I’m going to get right to the newsletter, without any big introduction. I will say in advance that this is going to be a shorter newsletter, for reasons I’m about to explain.

As always, questions, comments, and all feedback are much appreciated. And thanks for your interest in what I have to say and do!

What Are You Thinking? => Bimonthly Newsletters

First of all, how difficult is the English language? The term “bimonthly” means both every two weeks and every two months. Seriously? Yikes. Well, the reason I bring it up is that I’m thinking of changing the frequency of the newsletter. Right now, I try to send out the newsletter every 3-4 weeks, and target keeping it under 3,000 words (which I often don’t do). I’m debating putting it out every two weeks (-ish), but cutting the length by about half (as a point of reference this newsletter is the approximate new length). I’d also have to change some of the structure a bit. For example, I’d probably drop the “About This Newsletter” section, and only do some sections some times. What do you think?

You can reply to this email with your thoughts, or quickly vote at this online poll. Thanks in advance for your input!

On the Web => How To Read a PHP Function Definition

It was recently pointed out to me by a couple of readers that they found my explanation for how to read the PHP manual, presented in Chapter 1 of my “PHP for the Web: Visual QuickStart Guide” book, to be confusing. I think that learning how to read the manual is quite important, but I can see now that my presentation of that subject was a bit much at that early stage of the game, at least for absolute beginners. In any case, in that forum discussion, someone shared a link to a page in the PHP manual titled “How to Read a Function Definition”, which they found to be useful. So I thought I’d share it here!

On the Blog => Finding Book Bonus Content

For many of my books, bonus content is made available through the publisher. Sometimes this is material that was intended for the book but had to be cut, such as an appendix or a chapter, and sometimes the material is a true bonus, such as a video screencast. Because it’s not clear for everyone how to access this bonus material, I recently posted instructions for finding bonus material on my blog.

Q&A => Do You Use Any Tools to Debug Your PHP Scripts?

Daniel had asked me this question and the truthful answer is that I generally don’t, crazy as that sounds. Mostly this is because I primarily write PHP code using a text editor, TextMate, that does not have a built-in debugger. That leaves me with using echo statements as my primary debugging tool. I know I can get XDebug working with TextMate on my Mac, I just haven’t felt the need.

On the other hand, I’ve used Zend Studio some, mostly for Flex+PHP development, in conjunction with Flash Builder, and Zend Studio does have a built-in debugger. Debuggers are nice—they report the values of variables, let you walk through code, and so forth, I just haven’t been driven to force myself to use one yet. Certainly if I were to use an IDE more frequently, I would get myself into the debugger habit.

What is Larry Thinking? => Testing Your PHP Knowledge

A friend of mine recently went on a job interview for a position as a PHP programmer and was given this prompt:

$a = 4;
$b = 5;
$c = --$b + $a++;

What is the value of $c?

This is just annoying. The question is trying to test knowledge of the impact that using the postfix and prefix versions of the increment and decrement operators have. In other words, will $b be decremented and then added to $a or will $b be added to $a and then decremented (and, of course, the same goes for the $a value, too)?

Besides being a meaningless example, in no way does this test one’s actual skills as a PHP programmer. It only tests one’s ability to memorize the rules of precedence. I, for one, always considered memorizing the precedence rules to be a waste of time. The list contains many esoteric operators that aren’t commonly used. More importantly, memorizing the list is only useful if you always remember the precedence list accurately. As soon as you slip up, you’ve created a bug. And even if you don’t slip up, relying upon precedence will lead to code that’s not clearly understood (i.e., that doesn’t clearly convey the programmer’s intent). That, to me, is bad code. When I look at that prompt, I don’t wonder what the value of $c is, but rather what the original programmer intended it to be. I know it undercuts the point of the test, but a real PHP programmer should have coded:

$c = (--$b) + $a;
$a++;

That code assigns the same answer to $c—8—and then increments $a, but is much, much cleaner. And, of course, some comments wouldn’t hurt!

It probably would not have gotten me the job, but that’s what my answer would have been. To me it comes down to whether the company is looking for someone that can memorize arcane rules, or someone that actually knows how to program. This is also why I don’t personally put much stock into certifications. Those are just exams that tests one’s ability to memorize and regurgitate rules. Certification exams have little reflection of real-world programming. For example, I might be asked on a certification test the order of the arguments for PHP’s explode() function, which I can never remember for whatever reason. On the test, I’d have a 50-50 shot of getting that question right, but in the real-world, there is a 100% guarantee that I’ll use the function correctly, because I’ll just look up its definition.

Years ago, I was a trainer for Borders Bookstores. As part of the training process, we’d have the new employee go on a treasure hunt to find a slew of books. Inevitably some trainee would get stumped and tentatively ask another, more seasoned employee for help. I loved that, because it accurately reflects the job: when you got stuck, you asked the person next to you.

Many books, tests, and even these simple employee tests put way too much emphasis on knowing facts. Being able to answer a question about a rule or function is not that important in the grand scheme of things. Being able to find answers to questions is far, far more critical. If you rely only on what you know, there will be a time when you won’t know, and then you’ll really be stuck.

Larry Ullman’s Book News => “Modern JavaScript: Develop and Design”

I just submitted Chapter 14, “Advanced JavaScript,” about two days ago, which means I only have two chapters left (whohoo!). One chapter will be on frameworks, in which I introduce both jQuery and YUI, probably the two most commonly used frameworks. The other chapter will be an example chapter using JavaScript with PHP (and HTML and CSS, of course). I’m thinking right now of doing an auction-like system, which would entail timers and Ajax and DOM manipulation and all sorts of goodies.

I will have those chapters done in the next two weeks, at the latest. I’ve also done the rewrites on the first 8 chapters, and have a few more of those to go. There will be supporting video screencasts to go with the book, and probably a couple of articles to be published online. The end is nigh!