Why I consider (MVC) Smarty templating inefficient

Most PHP developers (and other web developpers too) seem to evolve on a similar path which goes like this:

Step 1: take HTML pages an add PHP tags into them.

Step 2: Realize that on a large scale this is getting very hard to maintain.

Step 3: Learn about the MVC (Model View Controller) paradigm and begin to think it's cool.

Step 4: Use Smarty or another templating engine like that.

The way most of those templating engines work is basically this:
a) Do a ton of PHP processing in the framework and fill in variables.
b) Call smarty and let it fill in variables in a template.
c) Send the output.

The issue here is that during steps a and b, nothing is sent back to the user. The user is just waiting for a response. Sadly enough, steps a and b will take a lot of precessing time. So the user will wait quite a long time before he gets any feedback on his action.

Even worse, when the application gets bigger, step a will take even more time!
And the more complex page you request, the more time you'll be left in the dark...

This is why I don't like all those mainstream templating engines. I want to send output back to the user as soon as possible. I want to send the page header at the begining of step a. And as soon as something has been processed and is ready for display, I want to send it out.

The global processing time will be approximately the same, but if the user sees content begining to display immediately, instead of all the content displaying at once 2 seconds after clicking, he will get the (false but humanely useful) impression that the application is faster. (Please do not say AJAX here, it is so not my point :P)

I'm not saying MVC is a bad paradigm, I'm saying most implementations of MVC are flawed, and Smarty is the most common example of this in PHP. Because they do the M & C stuff and then they do the V (view) stuff at the end. In my opinion they definitely need to interleave all this a lot more.

In evoCore (b2evolution's framework) our approach is to have the Controller really control the processing flow. In other words: for every block of information the View wants to display, the Control will process data from the Model and immediately pass it to the View in order to display the result block by block.

Of course, this has drawbacks: you won't be able to change the block order of the output if it's hard coded into the Controller. But really, that's okay to some extent. Who really needs to move the global header and the global footer for example? This is what we use for the back-office.

However, for the front-office, we want more customization, and we want people to be able to rearrange blocks in any order. In this case we have a little more complex processing, where the View actually calls the controller everytime it needs to display something.

Anyway, in any situation, my point is: the View should not be handled last.

Efficient vs. effective

Guy 1: I am so efficient I can fold 100 parachutes in a hour.

Guy 2: I am so effective I can fold 100 parachutes and every single one of them will open right.

Would you rather give your parachutes to the efficient or to the effective guy?

Now what I'd like to know is why all these programmers we interview pride themselves on being efficient?

I'm so sick of their industrial strength bug generating skills... :/

iPod podcast listening frustration

Today, I've got this massive stack of clothes to iron... bleh :(

To make the experience a tiny little bit more pleasant, I'm listening to every podcast on my iPod I hadn't listened to yet...

Great time to catch up with all that stuff... but great frustration too!

A typical podcast has an average length of 15 minutes. And when the iPod is done with playing it, it just goes back to the main menu. Yes, that's the MAIN menu, not the podcast feed you where in, not the podcast menu either! It's all the way back to the main menu!

So you need to drill down into the podcast menu again and then into the feed you were listening too, select the next podcast you want to listen to and then, finally, you can continue to listen...

Wouldn't it have made sense for the iPod to automagically playthe next episode in the feed I was listening too!? Isn't the whole podcast concept somewhat supposed to mimic a radio with better programs? Do you need to click on your radio in order to listen to the next show?

Apple seems to have thought this through... at some point... but only halfway I guess: you can actually press play when a podcast feed is selected and the whole feed will get played. But in this case you'll suffer 2 major problems:

  • You'll listen to the feed in reverse chronological order. And you'll hear feedback on the previous episode before you hear the referred to episode! :(
  • You'll listen to everything, including the episodes you've already listened to before...

This second point is something else that has been bugging me for a while: there's no way you can see on your iPod what episodes you've already listened to and which ones are new.

Each episode definitely needs a 3 state icon in front of its title, indicating wether it's unplayed, partially played or completely played.

What bugs me about iTunes & the iPod

iPod Sync options in iTunes

I gotta spit this out, because it really really starts to bug me bad! >:-[

I have all my CDs in my iTunes at home. And I have all of them auto-synched to the iPod. Then I take my iPod to work, and guess what: I'm expecting to listen to my mp3 files on my work computer! (Creating playlists, etc...)

Is that demanding too much?

I guess not! But, then, why the hell is it made soooo hard for me to achieve this? :!::?:>:-[>:XX

First problem: You can't copy the mp3 from your iPod to your secondary iTunes (the one on the Work computer).

Second problem: You can, however, have iTunes play the mp3s directly from the iPod through the USB connection... BUT this requires you to unlink the iPod from your main iTunes (the one at home). You can relink it later but this is a boring operation full of boring clicks. And you get to do it twice a day!

Third problem: The more you organize your music and the more meta data you add to it (genres, years, album art, personal rating...), the more you get to enjoy it and the more useful the "smart playlists" get... BUT: try to add a little meta data to your iPod songs while you're at work, then go home and try to sync: everything gets overwritten from the home iTunes and you loose all your meta data -- except the personal ratings. (Those ones are not stored as IDv3 meta data. They are stored separately in the iPod Database).

This is so decieving! So decieving from Apple. So decieving from a company that pushes another smart sync tool (iSync) but won't even bother to do a simple 2 way sync based on 'last changed' file dates! :(

I've looked through half a dozen 3rd party tools allowing you to copy from the iPod to iTunes/PC but none of them is working really like I'd want it... Especially, none of them will let me find and copy only the mp3s I've touched during the day... and brute force copying back all 5000 files is a little too tedious... |-|

Dating a geek

"The nice thing about most computer boys is that they don’t typically check out other women. The downside of this is that they don’t notice the other women because they are too busy checking out people’s cell phones and iPods."

Ever wondered how your girlfriend feels about your overall geekiness? This post on "Dating an Apple Developer" [site gone] is a gem. Nice template design too.