I get the impression that most people who are using objects in their
PHP projects are mixing them with procedural code. The design, I
think, is one where the procedural code is the client code, and the
classes are a library of utility code.
As such, when I've asked about how to get globals into objects, I've
been told that I should pass them in as the parameters to a method.
Easy enough if you have some procedural code. This answer I've been
given assumes that there is something outside of the object, some
procedural code that can get hold of the global and then hand it to
the object.
However, am I wrong in saying that if you wanted to go pure OO, you'd
have to grab the globals from inside of the objects? You could limit
this to the constructor, and possibly you could limit to just a single
master object that contained all other objects, but still, you'd have
to do pull globals straight into the object, yes?
PHP projects are mixing them with procedural code. The design, I
think, is one where the procedural code is the client code, and the
classes are a library of utility code.
As such, when I've asked about how to get globals into objects, I've
been told that I should pass them in as the parameters to a method.
Easy enough if you have some procedural code. This answer I've been
given assumes that there is something outside of the object, some
procedural code that can get hold of the global and then hand it to
the object.
However, am I wrong in saying that if you wanted to go pure OO, you'd
have to grab the globals from inside of the objects? You could limit
this to the constructor, and possibly you could limit to just a single
master object that contained all other objects, but still, you'd have
to do pull globals straight into the object, yes?
Comment