Re: Question regarding OO
| From: | Robert Cummings | Date: | Fri, 11 Jul 2008 16:11:32 +0000 |
| Subject: | Re: Question regarding OO | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-276656@lists.php.net to get a copy of this message | ||
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