|
Posted by Jerry Stuckle on 02/01/06 14:55
Erwin Moller wrote:
> Jerry Stuckle wrote:
>
>
>>
>>Yes, bad programming. It binds all of your code to the variable
>>$connection, among other things.
>
>
> No, I use it only in functions that need the connection.
> If a script needs the connection it gets the connection by means of a
> include at top of the script.
>
Yes, and declaring something global has its own overhead.
>
> If you need to change that you have a
>
>>huge amount of code to change.
>
>
> Why should somebody want to change the connection-object?
> It is needed for database-access.
> If I need to change that I am really making a new program.
>
Well, lets say you change hosting companies - and the new one uses
PostGres. Or you want to use the code on something which requires
Oracle access. Or any number of things.
>
> It also makes the code less portable.
>
>>Also, if $connection gets changed someplace, you'll have a hell of a
>>time trying to debug it.
>
>
> Sorry, thanks for replying, and I do not want to pick a fight with you, but
> this doesn't make sense.
> I can say the same for your object-oriented approach, look:
>
> - If you use an (singleton) Object to deliver the connection, you bind all
> your code to that object.
> and
> - If the connection in the object somehow get changed, all code breaks.
> and
>
First of all, it was not MY singleton object. But it's a heck of a lot
more portable than yours is.
Yes, you bind your code to that object. But that object itself can
change. Right now it uses MySQL. Later it can use Postgres, Oracle or
even flat files. No change to the code using it.
> Does that make sense to you?
> Of course not!
Of course it does!
> You know where you need a databaseconnection and get it delivered somehow,
> singleton Object or global connection.
> Both are lines of code, and both deliver the same in the end: a working
> connection.
>
But an object is a lot more than a line of code.
>
>>Globals in general are bad ideas.
>
>
> Not if you need an outside variable inside a function.
> It is perfectly legal.
>
And this one statement tells me that you've never worked in a commercial
programming environment. What's "legal" is not necessarily "good
programming practice".
> I could also deliver the connection by refrence every call to every function
> that needs the connection.
>
> No big diff.
>
Huge difference. But you obviously have made your mind up. Just please
- don't promote your poor programming practices on naive new programmers!
> Please remember that we are NOT talking about globals as in ASP
> (Application), but just globals for the duration of the script.
>
Yes, I know EXACTLY what we're talking about!
>
>
>
>>Citrus's design is much better. There is a little overhead - but not
>>all that much.
>
>
> Yes, Citrus claimed the same.
> Also without any argumentation that made any sense.
>
> If you are so sure of the superiority of the Object approach, why can you
> not tell us why?
>
I tried. You obviously aren't listening!
>
>
>>And I find objects almost always improve the structure of my code. It
>>also makes it more flexible and configurable. For instance - I can
>>easily change databases simply by changing the database object. No
>>changes in my code are necessary.
>
>
> No changes in your code needed?
> Of course you need to change something in your code, the Object that makes
> the connection is changed by you.
>
No, the OBJECT code changes. MY CODE does not!
> Now compare this to an include that delivers the connection: I also have 1
> place to change the connection, and it is included everywhere.
> Then everywhere where 'global $connection;' is used, the connection is
> up-to-date.
>
> Don't try to sell nonsense to me.
> I developed years and years in Java, and do not fall for laymans arguments.
>
I've been programming since 1967 (in Fortran I). I've written C++ for 18
years, some of them as a programmer for IBM. I've been writing Java for
over 10 years. And since then I've been a successful consultant,
writing code and managing projects.
Hardly a layman.
> Please give me a serious response that dives into the issue instead of
> claims that are clearly not true.
>
I have, but you obviously have made up your mind.
>
> Another thing: In PHP Objects are only halfhearted and last only for the
> duration of the script. They are not persistent. (Unless of course you
> serialize and deserialize them from script to script, but that is not
> exactly persistent.)
So? The same is true for any program!
> Object in PHP are nothing more than a bundling of some functions together,
> and their own namespace. Really that is all there is to it.
>
And you obviously don't want to understand.
> Don't try to make more of it than that.
>
>
> Heck - I can even use flat files when
>
>>necessary!
>>
>
>
> So can I, but what has that to do with this issue?
> Are you suggesting that Objects are the next step in evolution of the
> $connection in scripts? Haha.
>
The fact is - I can do it without any changes to my code!
>
> Regards,
> Erwin Moller
>
But this conversation is at an end. I don't argue with close-minded idiots.
Here's a tag line for you:
"My mind is made up. Don't confuse me with the facts!"
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|