RE: Multiple Inheritance

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

 



> Have you ever written a project and then moved to the next noticing that
> you are doing some of the same things from last project (connecting to a
> database, reading a file, writing to a file, etc...)?

Not quite the same thing.

When it is exactly the same thing, I just copy & paste the code.

Or, more likely, already have done that and changed it to a function.

> Have either of you ever written a for loop? Of course, you have.

Sure, though not very often.  I use while() a whole lot more.

> Have you ever written the for loop and then noticed (after you uploaded
> the script to the server) that you wrote the loop with syntax errors?

Rarely.

And only a very very very tiny percentage of my time is spent fixing typos
in syntax errors.

I spend a *LOT* more time, digging through endless class files, of what
are essentially name-spaces of singleton "objects" trying to find the line
of code some idiot typed that is doing the wrong thing, but starting from
'index.php' I have *NO* *IDEA* how it got in there.

I end up having to "grep" source code just to find the damn thing.

This doesn't happen in good code, whether it's OO or Procedural.

My point remains:

Inexperienced programmers being pushed to write OO code are going to write
*WORSE* code than inexpereienced programmers being forced to write
Procedural code.

The exception is if you have a fairly large TEAM of programmers, one of
which is a *VERY* experienced Architect who designs the OO framework, and
the less-experienced Programmers code the details on that framework within
the confines of the framework.

What I continually run into, however, is an inexperienced programmer,
grossly mis-using OO bits and pieces, in ways and means that make
unfathomable code.

I truly believe we should simply not encourage inexperienced programmers
to *design* systems, on their own, with OO (except as an exercise).

You just end up with this larger mess of objects flying around in no real
order or pattern that makes any sense at all.

> If so, why not use an ArrayIterator?  If not, then you are a master in
> the PHP realm.  I would have to assume that even the most experienced
> php developer has done this once or twice in there life. It all amounts
> to a waste of precious programming time. When this occurs.  Especially
> when TIME = MONEY.

Hmmmm.  Let's see.

You want me to learn a whole new syntax, with a whole new ArrayIterator
thingie, so I can have more syntax to memorize, and get wrong, and so I
can type more, and so I can have more lines of code to maintain.

No, thank you.

Been there; done that; hated it.

And I had *more* syntax errors, not less.  Not to mention *more* bugs,
sometimes very subtle bugs, introduced by the stupid Iterator classes.

It's really really really hard to not understand what:
for($i = 0; $i < 10; $i++)
does after a few weeks of study.

The same cannot be said of the ArrayIterator counterpart.

> What if you were to build an application around the MySQL database.  You
> have just finished the project and you are taking it to your boss.  You
> get there and then your boss says, "you know what I would rather use
> Oracle as our database".  With this situation you have, potentially,
> wasted many hours writing the MySQL version.  What are you going to do
> now, say something like, "Sorry boss, my application I designed is not
> flexible enough for me to switch db's at this time.", as your promotion
> for completing the project goes down the drain.

Hey boss, I wrote this application with performance in mind, and switching
to Oracle will be very easy, but some of the more complex queries will
need to be tweaked once we find out which ones Oracle excels at.

How many real-world users switch from MySQL (free) to Oracle (very not
free) with such short notice?

> There are large arguments about both, I grew up on OO so that is how I
> program and that is what I know.  Procedural does not even make sense to
> me.  Using low-level functions and process over and over again, when the
> functions and process can be written once and used on many projects over
> and over again.

I grew up on OO, using it extensively after one (1) semester of PL/1 in
college, continuing to use it for over two decades, and will happily use
it WHEN IT MAKES SENSE.

If you view procedureal programming as not re-using code, then you're not
writing good procedural programming.

More importantly, your OO programming probably isn't all that re-usable
either, as the basic rules and paradigms of code re-use transcend OO and
procedural implementation.

> Also, do you ever go back and maintain projects that you have worked on
> a year later.  If you used objects you would know exactly what you are
> walking into, I doubt you can say that with a procedural state of mind.

Bull!

Bad OO programming, or Bad procedural programming will make
un-maintainable code.

The converse is also true:  Good procedural programming is just as easily
maintained as good OO programming.

I've had to fix a *TON* of other people's PHP scripts.

Their OO scripts are almost always a morass of inexplicable relationships
having no useful purpose from efficiency, readability, or maintainability
stand-point.

While their Procedural scripts are equally broken, you can at least trace
what they were doing in something in a short period of time, rather then
the *DAYS* you waste with their bad OO code.

Let me put this succinctly:

Truly good OO code is better than Good Procedural code.
Bad OO code is way way way worse than Bad Procedural code.
Inexperienced Programmers write Bad code.
The conclusion is left as an exercise to the Reader.

> I don't care if you program in procedural or oo, but I would like you to
> educate yourself in the pluses and minuses of both.  If you have not
> learned oo and know nothing about it, then learn it might surprise you.

A month ago a guy wrote me about some Lisp code I wrote -- 10 YEARS AGO.

It's still in use today, it's very much OO, and he's been maintaining it
since I turned control over to him.

He's made some changes, some larger ones just now to comply with
OS/software updates, and he wanted me to look them over.

The catch:  This is the first I've heard from the guy in 10 YEARS about
this code.

Still think I don't know OO?

> I think the main problem is that PHP is still young in the OO world, it
> grew up on procedural.  With this in mind there is no OO Standard that
> people follow, like in Java, or .NET.  Pear is trying to address this
> issue, but if you are not a Pear believer then you use some other
> Standard, and so the cycle of NO STANDARD revolves.

Please don't even get me started on Java, much less .NET -- or Pear for
that matter.

-- 
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