I don't know about that... Using Zend class naming standards, __autoload was a simple str_replace('_', '/', $className).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.
Namespaces are here!
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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.superdezign wrote:I don't know about that... Using Zend class naming standards, __autoload was a simple str_replace('_', '/', $className).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.
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;True. I'm just afaird of the following:superdezign wrote:I don't know about that... Using Zend class naming standards, __autoload was a simple str_replace('_', '/', $className).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.
"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.
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.
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.
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
http://toys.lerdorf.com/archives/38-The ... ework.html
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?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
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
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.Everah wrote:I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?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
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
I just read a good bunch of the comments, and sure enough there are many people that feel the same way.Everah wrote:I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?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
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.jason wrote: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.Everah wrote:I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?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
Quantity != Quality. Consider the number of people that complain about the fact that he isn't filtering any of the input.Jcart wrote:I just read a good bunch of the comments, and sure enough there are many people that feel the same way.Everah wrote:I know he is the creator of our fine language and all, but was anyone else turned off by that sample code?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
Hint: He is. (php.net/filter)
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
PHP was a bunch of good ideas and a nice community, the initial implementation was shocking. Apparently he's a very entertaining speaker though.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.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
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...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.