|
No. It is the other way around I'm thinking. Class.forName given a
name as a string gives me the corresponding Class object, which can then
be used to do whatever, like creating objects and so on. Very powerful
stuff reflection is. This is generally rarely used since the compiler
cannot help you in any way (the string is first given at runtime), as
opposed to just "new WhateverObject".
It looks like that is what you do too in your snippet. My argument is
that by doing this, the compiler cannot help you, and your programs get
more brittle which makes it easier to break if you need to do major
maintainance.
By saying "new User()" in Java the compiler knows all about the User
class and can complain if your code is broken.
Just to be certain - does the PHP _compiler_ know if you write "$userObj
= new User()" that $userObj is a User and that only operations provided
by the User class is allowed, or is this only checked by the runtime?
Ok. So you are basically saying that you PRAY that the previous
You can state the type for objects and arrays. You don't have to, but you can and should. I probably write my code in a more structured manner than > a lot of PHP developers, but a good portion of them are really starting to take architecture seriously and building well defined class, interfaces and > such... and actually FOLLOWING a defined architecture. PHP has a bit of a reputation as a fly-by-night language. Some of that is deserved but new > applications are being built much better than even just 2 years ago. So, yes. I'm seeing a lot of new development following proper OO patterns, more or > less.
programmer did the program nicely :)
Praying is good - makes you think about what is important in life :D
I am as I said genuinely curious about this :)
Excellent! Curiosity kills only cats.
He he. You know http://thedailywtf.com/ ?
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.