On Plumbing
July 9th, 2008 (18:12 CST)Note to self: next time the bathtub won’t drain, first check to make sure the plug is open **before** you assume it’s clogged and pour 2 1/2 bottles of Drano down the pipe.
Note to self: next time the bathtub won’t drain, first check to make sure the plug is open **before** you assume it’s clogged and pour 2 1/2 bottles of Drano down the pipe.
After using the Zend Framework for a while, Enygma at phpdeveloper.org decided it was time for a change. The site is now powered by Solar. Thanks, Enygma!
Update: This entry seems to be getting a lot of new attention; welcome! The lessons of line length, volume, and density, along with lots of other good design principles, are applied to the Solar Framework for PHP 5. Be sure to give it a look if you’re interested in well-designed PHP code.
When it comes to coding style, there are are various ideas about how you should write the individual lines of code. The usual argument is about “how long should a line of code be”? There’s more to it than that, though. Developers should also take into account line volume (”number of lines”) and line density (”instructions per line”).
I remain unconvinced of the benefits of test-first and test-driven development (TDD) because I think the underlying principles of TDD are lacking, not because of the way TDD adherents talk about those principles. I believe I understand the test-first adherents very well, and I disagree with them.
… that means it’s probably a **good** idea.
http://blog.thepimp.net/index.php/post/2008/01/24/Say-NO-to-CLA-in-PHP
</snark> ;-)
This guyHasin Hayder has finally realized that there’s no need for Smarty’s template language any more (even after writing a book about Smarty).
Harry Fuecks and Brian Lozier made the same conclusion four years ago, and based on those articles, so did I. It turns out that Smarty tries to solve (mostly) the wrong problem
You may have heard that you need to keep your PHP and HTML separated, but that’s not quite the case. Instead, what you need is to keep your "business logic" separate from your "presentation logic", and that’s a different thing entirely.
Thus, all that’s required is a way to keep your views and controllers separated, and perhaps provide helpers for common view tasks. Then you can use plain PHP in your view scripts (templates), without needing a whole new language.
That line of thinking led me to write Savant first in 2004 (and versions 2 and 3 later), along with its more-recent ideological descendants Zend_View and Solar_View. Even the Cake and Symfony guys got the point early on (and — dare I say it? — the Rails crowd as well with eRB templates).
It’s so funnny to see the comments in Hasin’s article; all the same old tired arguments come up. Here’s the deal: if you think you need to protect your business logic from your graphic designer, you don’t have a technical problem, you have a hiring/management/training problem.
Update (2008-01-11): Apparently some readers thought “this guy” in the first paragraph meant me; changed it to “Hasin Hayder” to be more explicit. (I’m looking at you, Kimsal.)
The last time I wrote about Dirk Karkles, we learned that “do your best” is not a managerial plan of action.
Dirk Karkles thinks he can pay attention to more than one thing at a time. For example, he thinks he can write a report and carry on a phone conversation (or an IM/IRC session) at the same time. “I’m multi-tasking!” he says, sometimes with pride.
To this I say: There is no such thing as multi-tasking, there is only attention-switching.
You cannot perform two or more non-trivial tasks at the same time; at best, you pay attention to one and mostly ignore the other, then you switch your attention to the other and dismiss the first one temporarily, and then you switch your attention back to the first again. This is far less effective than completing the first task, then moving on to the second task, because of the time and mental effort it takes to switch between tasks.
Attention-switching is particularly bad when you are in real-time or near-real-time conversation. If you are doing other things while talking with someone else by voice or IM/IRC, you’re telling the other person they are not worth your full attention. If they’re not worth your attention, why are you worth theirs? (”I’m the boss” and “I’m paying them” and variations thereupon are not valid arguments — try again.) You are wasting your time, and theirs, by not being a full participant in the conversation.
Now, there are times when you must give your attention to multiple tasks. Be aware that you are not multi-tasking, you are attention-switching, and take this into account when you switch your attention to another task. At the very least, you will need to take time to “catch up” on the task before you perform some new action related to it. For example, in an IM/IRC conversation that you are taking active part in, you will need to read and comprehend the backlog of messages before you you can even think about writing a meaningful response. Among other things, this means that attention-switching is not a net time saver, it is a net time spender — but sometimes you have no other option.
So, the next time some tells you “I’m multi-tasking!” you know that person is not paying full attention to anything he’s doing right then. Similarly, if you find yourself attention-switching in live conversation, have the common courtesy to excuse yourself and pick back up again later, when you can give it your full attention. “Multi-tasking” is something to apologize for, not to be proud of.
Quick note to say I’m moving my blog from Pair.com to my new WebFaction space. Layouts, etc. will be different until I copy over themes and other images.
Without having done actual research, and depending on my personal experience alone, I would assert that in PHP userland …
Dispute the specific numbers all you like; they’re not the point. The point is that CMSes, frameworks, template systems, etc. seem to be a very common artifact among PHP developers, but writing (and then publishing) unit-test systems does not seem anywhere near as common an obsession.
What does this say, if anything, about the attention given to unit-testing among PHP developers?
Note that this is an *off-the-cuff opinion* and a *request for comment*, and nothing else. (Some folks get testy about testing; please remember to be nice while commenting. ;-)
Update: And there are only 3 or 4 documentation systems: PhpDocumentor, Doxygen, and Solar_Docs, along with the various combinations of DocBook tools that Zend, PEAR, and PHP are using. I wonder how that enters into it, if at all.
Those of you who know me well, know that I am not much of a TV watcher. What little I do watch is boring to most normal people; by way of example, note that my 10-year-old 25″ RCA tube has the C-SPAN logo burned into the bottom right corner.
So for me, this article feels like vindication:
How Dumping TV Allowed Me To Quit My Job…
Not that I’m rich by any means, but you get the point — TV is usually a soporific time-waster. Watch less TV, get more “real” stuff done.