[thelist] php design question

Joel Canfield joel at spinhead.com
Tue Nov 19 02:07:01 CST 2002


--
[ Picked text/plain from multipart/alternative ]
> if i want to use an include, i go "include navbar.txt"
>
> if i want to use a class, i say "dance, nav bar, dance" and
> go "navbar.show()"
>
> i still don't see the difference, but boy oh boy, i do hope
> they ask me this on my next job interview

My turn ;)

Going way *way* back to very very basic, in case that's what you meant all
along (and putting it in a practical 'why should rudy do this or that'
perspective):

Includes are procedural. Objects are not.

I want the cat to leave the back yard. I can write a lengthy procedure
detailing the steps required for the cat to leave the yard. It is
complicated, but I am smart.

On the other hand, I can simply introduce an 'object' (how about a dog?)
which has a 'method' (maybe, chase?) which will make the cat leave. Simpler,
more direct *as long as the object and method already exist.* If not, I can
create the object, and then use it over and over again. Um, just like an
include.

There are probably a zillion efficiency reasons to use objects whenever
possible. It also sounds cool to say you know something about
object-oriented whatever (and acronyms that start with 'OO' are the bomb.)
But in real life, if you have to create the object, or you have to create
the include, you're probably doing about the same amount of work, and
getting the same results.

Here's where it's different for me: I *think* in object-oriented whatevers.
So, if I have an include that, well, includes the procedural procedure, it
works fine, but I can't always remember what it does (or how) without
peeking at the code. But if I build an object with a bunch of methods (which
may be functionally identical to the include right over there) it's easier
for me to remember *what* my object can do and *how* to do it - I'm not left
struggling to get the syntax correct, it flows naturally because it's how I
think.

Some of you old guys (I crack me up) think procedurally, and that's your
natural state. Unless you are already convinced that you need to use objects
instead of includes, don't bother. When you have a need which makes an
object superior to an include, you'll probably recognize it and figure it
out for yourself. In the meantime, grow your hair, get things pierced, and
write procedures.

Close? In the ballpark, even?

joel



More information about the thelist mailing list