NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Writing get and set methods is boring
Veteran

Joined: 30 Nov 2006
Posts: 186
Reply with quote
Hi is there a way to automate writing get and set methods in classes?

99% of the time the get and set methods are the same.

Any hints?
View user's profileFind all posts by hgrSend private message


Joined: 19 Aug 2006
Posts: 76
Reply with quote
Integration scripts... I customized one I found there to fit my needs.
View user's profileFind all posts by jlSend private message


Joined: 14 Aug 2009
Posts: 35
Reply with quote
use symfony!
View user's profileFind all posts by cr0wn3rSend private message


Joined: 10 Jul 2009
Posts: 1
Reply with quote
Why don't you use a base class that already has a good get and set routine? EG:

Code:

class myBaseClasse{
    public function set( $key, $val ){
        $this->$key = $val;
    }
    public function get( $key ){
        return $this->$key;
    }
}

class newClass extends myBaseClass{
    // This new class already has functionality for get and set
}


PHP is limited in that you can only extend one class at a time but there are some very creative ways to still work around this limitation.
View user's profileFind all posts by ledeSend private message
Writing get and set methods is boring
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic