[thelist] php design question

Andrew Forsberg andrew at thepander.co.nz
Mon Nov 18 17:59:00 CST 2002

> could somebody please explain (offlist is okay, because obviously i'm
> slow)
> how is an object different from an include?

ooh, ooh, this is always explained by analogy, so can i have a go?

includes, as you know, are a file system level control of what goes
where. objects and classes -- a different way of programming --

let's say we have a class called 'cocktail', and we have another class
called 'martini' -- the martini class says 'i am a cocktail, but a bit
more specific'. so the martini class extends the cocktail. the martini
then inherits stuff from the cocktail, and changes details here and

now, say we want to build a martini, that's when we make an object. the
class is like a factory (the martini recipe, sort of), the object is
the thing (the thing you drink).

each object (and class) has its own variables, and methods (functions,
whatever...). and they can override each other. so -- the cocktail
class can have any sort of potable / edible ingredients as long as
there's more than one alcoholic thing in it (otherwise it's a
'mixedDrink' class), but the martini class can only have gin, vermouth,
and either a twist of lime or an olive. the cocktail class might have a
'shake()' method, but the martini class would override that and make it
an alias to the 'stir()' method (or, generate an error).

>>> Two words; objects and classes. (see below)
>> IMHO: Don't believe the hype.

it always confuses the crap out of me in the php context, and on so
many levels. so:

> This could be the topic of a religious war; I won't bother defending my
> opinion in the hopes of sparing the list of unneccessary traffic.

roger that.


More information about the thelist mailing list