Archive for December, 2007

Zend Framework Components – Part 1

Friday, December 14th, 2007

By: Jonathan Lebensold

Why aren’t you teaching me how to make a blogging / shopping cart application?

Because the Pragmatic Programmers did a fantastic job when they wrote their famous Rails book “Agile Web Development with Rails.” Crowds ooo-ed and aaa-ed when the rails camp wrote tutorials that described “how to make a blog in ten minutes using Rails.” PHPCake responded. They wrote a tutorial, and then people writing about Zend did the same thing.

When Stefan asked me to write about the Zend Framework, I decided I would avoid copy-able code, simply because it doesn’t re-enforce good software design. I’ve also read through many of these tutorials (most of which are excellent), however they tend to be misleading for several reasons:

- They don’t presume a complex view (with headers and footers that have dynamic logic)
- They don’t introduce core object libraries, but rather skim past them to get to the event-driven stuff (found in Zend_Controller, which I’ll cover soon)

(more…)

A Question about object properties in PHP Classes.

Thursday, December 6th, 2007

I got this question put to me recently:

Since you say it’s bad practice to access object properties directly from outside the class, is it then good practice to declare all variables as protected or private to force yourself to not?

My answer:

Yes.

Many OO techniques are designed for situations where you will have more than one programmer involved, now or later. By declaring variables as protected or private, you are adding security to the code base by forcing the use of getter and setter methods where you can control how objects are used.

The thing is that with PHP, since the code is not compiled a programmer could just pop open the script and make changes. Whereas with compiled languages like Java, the users of your class have no choice.

… Unless they decompile the class!

Top of page  go to top of page