Page 2 of 2

Posted: Fri Sep 19, 2003 4:50 am
by Heavy
In response to jason:
I continued here.

Posted: Fri Sep 19, 2003 2:52 pm
by McGruff
Heavy wrote:In response to McGruff:
What is "Camel back var names"?
I wouldn't presume to tell you what your coding style should be :) Personally I stick to most of the PEAR guidelines http://pear.php.net/manual/en/standards.php. Camel back names refer toTheWayThat new words get aCapitalLetter (except the first). That's usually used for function names: $vars_would_be_written with underscores separating words, lower case. So some of your vars looked like fns to me. That's the point of coding standards: makes it easier to work together. Not that anyone's more right than anybody else or that everyone's ever going to agree on a single style. Your var names were pretty good ie descriptive that's the main thing.
Ummm... If you do a print_r($arrVarNames), you'll see that it [.. the populate fn..] works.
I didn't think get_class_vars would work in the constructor since the class hasn't been properly initialised yet. Still not easy about that..

This works fine:

Code: Select all

<?php
class Bar
{
    var $var1 = null;
    var $var2 = null;
    var $var3 = null;

    //..etc
 
?>
You can initialise constant values but you're correct to say that you can't assign things like date() etc.
Also. Looking at your reply. What happens if you create two different objects of the one of your classes? You break the property references to the session! I passed the name of the object to the constructor to distinguish between objects, not classes.
I maybe didn't pick up on that behaviour. Sure: pass a string in and use that.
Indeed. I don't get what you are talking about. You are using the same $_SESSION global as I am, and you are not protecting it from beeing accessed any more than I do.
Yes. The code I posted passes vars to session by ref same as your own. I was thinking out loud if it might not be a good thing to do for the above reasons.
I question that your code has been tested, because:
  • $this->fooVar = 10; cannot point to var $foovar;
I guess you mean the typo. Guilty as charged (see what I mean about coding styles?). There wasn't any need to test a sample script - it's just there to show what I think is a slightly clearer way to do what you're doing. I don't like the populate fn: I have to stop and think about what it's doing (so will you in a few months time) but the other way I can see immediately what's going on - and also see at a glance what properties are set in the class.

Pretty minor differences, all in all.

Posted: Mon Sep 22, 2003 4:18 am
by Heavy
Apart from coding style opinions, we pretty much agree then.

One thing remains, and that is benchmarking the two different approaches and judging them by philosophy.
I am not asking anyone to do that for me.

I'll post some conclusion later... maybe...
Thank you guys for your input.