berridgeab Posted July 1, 2011 Share Posted July 1, 2011 Hi Just fishing for opinions here, is it a good idea to break classes down to skeleton parts? i.e. I have a class called Person. class Person { public $id; public $name; public $age; //Getters / Setters Go here function id() { return $this->id; } function load($id) { //Database loading logic here } } To something more reuseable i.e. abrstract class SkeletonPerson { public $id; public $name; public $age; //Getters / Setters Go here function id() { return $this->id; } } class Person extends SkeletonPerson { function load($id) { //Database loading logic here } } Link to comment https://forums.phpfreaks.com/topic/240870-skeleton-class/ Share on other sites More sharing options...
trq Posted July 1, 2011 Share Posted July 1, 2011 Yes it's a good idea to abstract as much functionality away you can into base classes. Just be aware though that php is only single inheritance, this means you can end up with long chains of relationships. Link to comment https://forums.phpfreaks.com/topic/240870-skeleton-class/#findComment-1237265 Share on other sites More sharing options...
berridgeab Posted July 1, 2011 Author Share Posted July 1, 2011 Thanks for the clarification. Link to comment https://forums.phpfreaks.com/topic/240870-skeleton-class/#findComment-1237280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.