On Fri, Apr 18, 2008 at 11:21 AM, Nick Stinemates <nick@xxxxxxxxxxxxxx> wrote: > On Fri, Apr 18, 2008 at 10:25:29AM -0600, Nathan Nobbe wrote: > > On Thu, Apr 17, 2008 at 5:43 PM, Nick Stinemates <nick@xxxxxxxxxxxxxx> > > wrote: > > > > > On Thu, Apr 17, 2008 at 10:05:11AM +0200, Michael Preminger wrote: > > > > Hello! > > > > > > > > Seems that PHP gets more and more object oriented, which is good. > > > > > > > > I am now running a course in PHP, using PHP 5, where we are going to > > > > use the *DOM* interface. I am trying to teach them good OO > practices, > > > > meaning that we insistently hide properties and expose them as get > or > > > > set methods. > > > > > > Get/set methods are more often than not breaking encapsulation and > > > should be avoided (unless purposefully designing Model object or > > > something similar.) > > > > > > > egh? we had a massive argument about this last year, but if u ask me > data > > hiding is an integral part of encapsulation; therefore i agree w/ > Michael. > > > > Data Hiding IS Encapsulation. > > But, you have to agree, > > <?php > > class Lol { > private $bar; > > public function getBar() { return $bar } > public function setBar($bar) { $this->bar = $bar} > > } > ?> > > Is no different than: > > <?php > class Lol { > public $bar; > } > ?> it is different, by your very definition. quote 'Data Hiding IS Encapsulation' so the difference in the 2 examples you supplied is that the first one is an example of encapsulation, whereas the later is not. encapsulation provides control. it reduces the possibility of client code binding to implementation details which decreases coupling. go into the archives, you will find the argument from last year. its in the same one about interfaces, that we pretty much re-hashed this week. -nathan