Page 2 of 3

Posted: Fri Aug 17, 2007 3:49 pm
by superdezign
jason wrote:_autoload was really cool... I thought. But the reality is that it just makes everything obfuscated.

include 'file' or require 'file' is the winner in my book. It's clear, precise, and does what it does.
I don't know about that... Using Zend class naming standards, __autoload was a simple str_replace('_', '/', $className).

Posted: Fri Aug 17, 2007 3:53 pm
by Chris Corbyn
superdezign wrote:
jason wrote:_autoload was really cool... I thought. But the reality is that it just makes everything obfuscated.

include 'file' or require 'file' is the winner in my book. It's clear, precise, and does what it does.
I don't know about that... Using Zend class naming standards, __autoload was a simple str_replace('_', '/', $className).
I think jason means you have to read the implementation to see what's used. In Java for example you can open a file and immediately see what APIs a class will be using*, but Java *does* have pretty rigid conventions forced upon you.

Code: Select all

/**
 * XML Reader convenience class.
 * Provides some wrappers around the DOM to save on typing.
 * Much of the functionality provided here is wrapped around XPath expressions.
 */

package org.w3style.util;

import java.io.InputStream;
import org.xml.sax.InputSource;
import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathConstants;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
*Unless you resolve class names with their package names prefixed throughout.

Posted: Fri Aug 17, 2007 3:57 pm
by jason
superdezign wrote:
jason wrote:_autoload was really cool... I thought. But the reality is that it just makes everything obfuscated.

include 'file' or require 'file' is the winner in my book. It's clear, precise, and does what it does.
I don't know about that... Using Zend class naming standards, __autoload was a simple str_replace('_', '/', $className).
True. I'm just afaird of the following:

"Suddenly in the middle of your 400 line file you make a call $obj = new Data_Obj(); which is all fine and dandy, except I won't see it!"

__autoload is useful to a point, but I'd still prefer to use include or require all the same so it clearly spells out what's going on, and when I come back to it a year later, I know what's happening (I speak from experience here).

Edit: d11wtq nails it.

Posted: Fri Aug 17, 2007 4:02 pm
by jason
Oh, and while I'm afraid of __autoload, I support auto_prepend et. al. Why? I mean, after all, this does auto-magical stuff for me. But the definition of what it's doing is defined in one clear location. There is no guessing. __autoload is defined any place you are including objects that haven't had their files included yet.

The other danger is what happens when an objects file can't be autoloaded? Suddenly you have transaction issues and have to plan for rollbacks. Knowing up front that a file can't be loaded, and that file is needed... well, it really helps.

Posted: Fri Aug 17, 2007 4:03 pm
by jason
Hate to keep replying to myself, but this is Mr. Lerdorf's article I was referring to in a previous post.

http://toys.lerdorf.com/archives/38-The ... ework.html

Posted: Fri Aug 17, 2007 4:26 pm
by RobertGonzalez
jason wrote:Hate to keep replying to myself, but this is Mr. Lerdorf's article I was referring to in a previous post.

http://toys.lerdorf.com/archives/38-The ... ework.html
I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?

Posted: Fri Aug 17, 2007 4:33 pm
by superdezign
Everah wrote:I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?
*raises hand*

I've grown to used to OOP to go back to procedural...

Posted: Fri Aug 17, 2007 5:13 pm
by jason
Everah wrote:
jason wrote:Hate to keep replying to myself, but this is Mr. Lerdorf's article I was referring to in a previous post.

http://toys.lerdorf.com/archives/38-The ... ework.html
I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?
Nothing really wrong with it, and despite that, the point of his article still stands. The quality of the code as far as an example where code quality is not the topic up for discussion doesn't matter.

Posted: Fri Aug 17, 2007 5:15 pm
by John Cartwright
Everah wrote:
jason wrote:Hate to keep replying to myself, but this is Mr. Lerdorf's article I was referring to in a previous post.

http://toys.lerdorf.com/archives/38-The ... ework.html
I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?
I just read a good bunch of the comments, and sure enough there are many people that feel the same way.

Posted: Fri Aug 17, 2007 5:19 pm
by RobertGonzalez
jason wrote:
Everah wrote:
jason wrote:Hate to keep replying to myself, but this is Mr. Lerdorf's article I was referring to in a previous post.

http://toys.lerdorf.com/archives/38-The ... ework.html
I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?
Nothing really wrong with it, and despite that, the point of his article still stands. The quality of the code as far as an example where code quality is not the topic up for discussion doesn't matter.
I think the struggle with what he posted is that n00b's tend to take code and run it, then look at it for something they can implement. It may not make a difference in the context he wrote it in, but it could make a difference when someone is too lazy to understand what he means and copies and pastes his code, then uses it as some form of 'Do it this way because he is the inventor of PHP' type thing.

Posted: Fri Aug 17, 2007 5:19 pm
by jason
Jcart wrote:
Everah wrote:
jason wrote:Hate to keep replying to myself, but this is Mr. Lerdorf's article I was referring to in a previous post.

http://toys.lerdorf.com/archives/38-The ... ework.html
I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?
I just read a good bunch of the comments, and sure enough there are many people that feel the same way.
Quantity != Quality. Consider the number of people that complain about the fact that he isn't filtering any of the input.

Hint: He is. (php.net/filter)

Posted: Fri Aug 17, 2007 5:22 pm
by superdezign
Everah wrote:because he is the inventor of PHP' type thing.
Whoa whoa.... WHAT?? Are you serious?? You mean like... He WROTE PHP?

Posted: Fri Aug 17, 2007 5:31 pm
by RobertGonzalez
Yes, like Rasmus was the guy that started the whole PHP thing with his crazy PHP/FI. Read the history of PHP in the Manual.

Posted: Fri Aug 17, 2007 6:42 pm
by Ollie Saunders
Everah wrote:Yes, like Rasmus was the guy that started the whole PHP thing with his crazy PHP/FI. Read the history of PHP in the Manual.
PHP was a bunch of good ideas and a nice community, the initial implementation was shocking. Apparently he's a very entertaining speaker though.

Posted: Fri Aug 17, 2007 6:58 pm
by superdezign
Everah wrote:Yes, like Rasmus was the guy that started the whole PHP thing with his crazy PHP/FI. Read the history of PHP in the Manual.
It wasn't until I read that that I realized that Zend was made FOR PHP instead of PHP being based on Zend. Yeesh.. misconceptions...