Re: class usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, September 29, 2006 4:35 am, benifactor wrote:
> ..and this seems to work fine, i could easily add  the mail function
> and insert real variables into send() but what i don't understand is i
> could also easily do this without a class... so i guess the real
> question is what are some real life examples of class usage and why is
> it used as  opposed to regular non oop? thank you for any input into
> the subject that you may have.

For something that small, using a class is ridiculous, bloated,
over-engineered pointless exercise.

Rather than type "ridiculous, bloated, over-engineered pointless
exercise" in this email again, I'll simply dub that "Wrong Answer" and
type that a lot.

In fact, for almost *ANY* small/simple problem OOP is the "Wrong Answer".

OOP shines, however, in some large-scale usage:

#1. One architect, many developers
If you have ONE project architect cleanly map out a Plan in the form
of a large class structure, with a clear and clean internal API, and a
bunch of junior programmers to fill in the details, the Architect can
use OOP with stub functions, just like you wrote above, to build the
framework, and the junior programmers can fill in all the stubs.

#2 Real-world parallels
Sometimes when modeling real-world parallels (or even Virtual World
parallels like game prototyping, windowing systems, etc) having OOP
leads to a very natural readable maintainable code-base, as the
operations and variables and the interaction between them mirrors to a
large extent the operation and interaction between their real-world
counterparts.

The biggest problem in OOP, in my experience, is that you have many
developers, like yourself, who begin using OOP solely because they are
told that "it's better"

Many of these developers then go on to write *BAD* OOP code, for all
the wrong reasons, in all the wrong places, to solve trivial problems
with the "Wrong Answer".

Many of these developers continue to use the "Wrong Answer" over and
over, and never actually utilize any of the strengths of OOP, but
instead train themselves to misapply OOP.  Their code "works" it's
just oftentimes the "Wrong Answer"

Unfortunately, learning to use OOP correctly is a long-term process,
and you have to do a bunch of trivial things with the "Wrong Answer"
just to figure out how it works -- Which means you really should re-do
them as non OOP, or be doing them solely as a means of learning and
not throwing them into Production.

Alas, this is not how 99% of OOP code in Production ends up in
Production...  All too often, it's the "Wrong Answer" that gets thrown
into Production.

This is not meant as a "dis" of the great OOP code out there.  I've
seen some very very very nice OOP systems in the past -- in Lisp, to
solve large-scale problems.

In PHP, to spit out a web page in under 1.7 seconds, not so much. :-)

I'm sure somebody out there has a GREAT PHP web application with a
complex backend all in OOP.  So far, all I've seen is "Wrong Answer".

YMMV

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux