Page 5 of 5

Posted: Tue May 15, 2007 6:12 am
by Chris Corbyn
kyberfabrikken wrote:
d11wtq wrote: These methods come in really useful at times. I use __get() and __set() in my abstract View component (just like many others do), but I also provide setVar() and getVar() in the View too. They're just convenience methods really.
I think arborint's point was that the implementation is sketchy. C#'s "properties" are a much nicer implementation of basically the same functionality.
Ah sorry, I misunderstood :)

C# is something I've yet to look at but have always felt held back by the fact I'm not a Windows guys and Mono confused the hell outta me :P

Posted: Tue May 15, 2007 6:31 am
by kyberfabrikken
d11wtq wrote:C# is something I've yet to look at but have always felt held back by the fact I'm not a Windows guys and Mono confused the hell outta me :P
Here's how C# does it:

Code: Select all

public class Foo
{
  private string __name;
  public string name
  {
    get { return this.__name; }
    set { this.__name = value; }
  }
}

Posted: Tue May 15, 2007 6:40 am
by Chris Corbyn
Ah, that's clever. It's like a refactored (albeit syntactically different) equivalent, more targetted at specific fields.

Thanks for the example, I agree that __get() and __set() do not do such a good job of this. I think the PHP developers are hard pushed to add new rules to the simplistic PHP syntax though. I suspect this is the same reason they are still faffing about with namespaces and leaving us wondering if they'll actually implement them.

You can direct calls to __get() and __set() with a simple swicth but I admit it's less readable than the approach C# have taken.

Apologies for derailing a thread about autoloading ~Everah :oops:

Posted: Tue May 15, 2007 10:34 am
by RobertGonzalez
d11wtq wrote:Apologies for derailing a thread about autoloading ~Everah :oops:
Aw, it's alright. This thread has been very educational for me.

Posted: Tue May 15, 2007 1:54 pm
by Christopher
kyberfabrikken wrote:I think arborint's point was that the implementation is sketchy. C#'s "properties" are a much nicer implementation of basically the same functionality.
Thanks kyber for the clarification and the excellent example. :)

For the record, I am not saying that I know that the current implementation is not the best one. And I admit it is workable and getting more workable. I think my concern comes from my belief that good design comes from implementation knowledge. Because I have watched Zend "learn as the go" about OOP and enterprise patterns like MVC as they build their framework -- and still not quite get it -- I am suspicious of their solutions in this area. However the chances that I am completly incorrect are, as usual, high.