Why OO? WAS Re: [thelist] php design question

Steve Lewis slewis at macrovista.net
Wed Nov 20 16:08:01 CST 2002


Max Kanat-Alexander wrote:
> At 11:20 AM 11/20/2002, Steve Lewis wrote:
>
>>Consider, the CSS classes used should belong to the object's class as
>>well to achieve 'total' encapsulation.
>
>          Only if you're /trying/ to combine content and presentation.
> Encapsulation only applies on a certain level. In the case of web
> development, encapsulation applies to the content data. I don't see why I
> can't generally keep my CSS separate. (Unless I'm mis-understanding your
> statement.)
I was simply making the point that if you output html such as <p
class="article">text goes here</p> than your CSS class definition of
P.article belongs to the article OO Class explicitly.  This CSS Class is
a property of the article OO Class, is it not?  And while you could
store { color: red; } or { color: blue; } in the class as a value for
that property, doing so gets you very little.

Yes, encapsulation does have it's limits, but as I said you have to know
the rules and understand the rules before you break the rules.  I would
not go so far as to put the CSS into the object either, but there is a
trade-off the developer must make in deciding where to stop encapsulation.

>          Even in application development, encapsulation only goes so far.
> If I write a program that has a GUI, in Java, it will /look/ different on
> most platforms (different fonts, etc) but will contain the same data.
Do you want to create a web-swing library?  I don't.  Generally, what
you will be doing as a web developer is feeding an object (my 'article'
object for instance) to an output stream handled by a client/server pair
which uses unknown and poorly defined and/or poorly implemented methods
to render the content.  This is much different than handing an object to
a java foundation class object which will format it for delivery to the
OS/window manager.  Without the well defined foundation classes for
display, web developers need help in this arena.

>          This is, of course, one of the things that widespread adoption of
> XML and XSLT will hopefully change.
here here.  I want to also thank Kelly for bringing up that the DOM and
Javascript are OO.  I suppose the problem, to restate clearly, is that
there is no perfect connection between an object in a
servelet/perl/php/whatever and the DOM on the browser.  We do not have
the seamless communication that would allow me to extend the DOM classes
to build a display-method for a servelet/perl/php/whatever class and
hand an object of that class to the DOM display-method.  That sort of
seamless communication is being hinted at with XSLT, with FlashMX & CFMX
integration, .NET applications, etc.  I still don't see evidence that
complete web-OO has arrived, though I look forward to it.

--Steve




More information about the thelist mailing list