Re: Question regarding OO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2008-07-11 at 18:03 +0200, Yeti wrote:
> <?php
> 
> /*
> 
> I have a question here regarding object orientation in PHP and any other
> language.
> 
> Let's start with some hypothetical code:
> 
> */
> 
> // <--- 1st CLASS
> 
> class ParkingLot {
> 
> var size; // size in sq feet
> 
> var max_number_of_cars; // how many cars there is space for
> 
> function __construct($size, $max_cars) {
> 
> $this->size = $size; $this->max_number_of_cars = $max_cars;
> 
> }
> 
> };
> 
> cpark = new ParkingLot(50000, 17);
> 
> // <--- 2nd CLASS
> 
> class ParkingSpace extends ParkingLot {

Here's the point of your comfusion. ParkingSpace is not really a
ParkingLot is it? I mean you could say a parking lot having a single
parking space qualifies, but not really. I see you problem being similar
to apples versus apple tree. You wouldn't do the following (would you?):

<?php

class AppleTree
{
}

class Apple extends AppleTree
{
}

?>

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux