Apr 19 at 3:46pm, Chris W. Parker wrote:
> Kelly Hallman <mailto:[EMAIL PROTECTED]>
> > I think what you're talking about here is encapsulation.
>
> in that case what is abstraction?
I suppose it's pretty similar, but I believe that encapsulation is the
pedantic term for hiding the data structure behind an object's interface.
I generally would consider something abstraction when it enables you to
access any number of things from a common interface, such as a database
abstraction layer is an API to interfacing to different RDBMS.
> >> PROPOSED CHANGE:
> >> class Customer {
> >> ...
> >> function initialize_customer($customer_id) {
> >> // grab data from db
> >> $this->fname = $...[0]['fname'];
> >> $this->lname = $...[0]['lname'];
> >> $this->age = $...[0]['age']; }
>
> i see my code has been run through the kellytron 5000. ;)
Dude, it just kills me to not compact the code, at least in a list post ;)
Python! Python did it to me!
> > class Customer {
> >
> > var $res = array();
>
> what does $res stand for? result?
Yeah. Generally, I like compact! :) However, I am consistent throughout my
code, so it makes sense if you spend enough time there....! :)
> > var $id, $fname, $lname;
> >
> > function Customer($id=null) {
> > $id === null || $this->initCustomer($id); }
>
> what is the above line equivalent to
Equivalent to:
if ($id !== null) { $this->initCustomer($id); }
The conditional:
if ($id === null) { $this->initCustomer($id); }
could also be written as:
$id === null && $this->initCustomer($id);
I just find that more succinct.
> and why is '$id == null' not sufficient?
Because where $id = 0;
($id == null) == true;
due to casting, yet
($id === null) == false;
=== is explicit equality, the operands must also be the same type.
also note that !== vs. != is like === vs. ==
for example:
null == 0 == false == array() == ''
where === would cause all to evaluate false
Doesn't mean it'd be insufficient, but it would allow you to pass a zero
to the method, and differentiate between it and the default value of null.
--
Kelly Hallman
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php