Namespaces are here!

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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).
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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...
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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)
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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...
Post Reply