Re: OOP leads to lousy websites?
From: Bruno Desthuilliers (bdesth.quelquechose_at_free.quelquepart.fr)
Date: 02/22/04
- Next message: david: "Authentication by the Server"
- Previous message: Bernd Liebermann: "Re: header redirection and adress bar"
- In reply to: Chung Leong: "Re: OOP leads to lousy websites?"
- Next in thread: Berislav Lopac: "Re: OOP leads to lousy websites?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 22 Feb 2004 19:26:11 +0100
Chung Leong wrote:
> Uzytkownik "Tom Thackrey" <use.signature@nospam.com> napisal w wiadomosci
> news:VUcZb.21$0A2.5@newssvr27.news.prodigy.com...
>
>>Your example is too trivial. Plus the error you avoid is essentially using
>>an undeclared variable. I'd rather have it fail catastrophically than
>>subtly.
>
>
> Not necessarily. The null can be returned from a function, or is an element
> not set in an associative array (in $_POST for instance). In 99 out of 100
> cases, the difference between null and an empty string is philosophical. The
> point is, there's no data.
The difference between null and '' is much more than just philosophical
IMHO. An empty string is not 'no data', not more than 0 is 'no data'.
> A more realistic example would be XML data extraction. To get an element
> with a particular id, the OO code would look like:
>
> $country = $doc->GetElementById('Poland');
>
> while a function-based API would yield this syntax:
>
> $country = xml_get_element_by_id($doc, 'Poland');
>
> Now say we want to get a list of its child-elements, the OO code looks like:
>
> $cities = $country->GetElementsByTagName('city');
>
> while the non-OO counterpart is:
>
> $cities = xml_get_elements_by_tag_name($country, 'city');
>
> If there is no element with the id 'Poland', the OO could fail
> castatrophically without additional safeguard, while the non-OO version
> probably generates an warning (which the users probably will never see)
(snip)
'would', 'could' etc... Why 'could' the OO version 'fail
castatrophically' and why 'would' the procedural one generate a warning?
this is just plain non-sense. The only correct behaviour *in both cases*
should be to return null, and the caller to check the return value.
If that's all your case against OO, there is no need to continue this
thread.
Bruno
- Next message: david: "Authentication by the Server"
- Previous message: Bernd Liebermann: "Re: header redirection and adress bar"
- In reply to: Chung Leong: "Re: OOP leads to lousy websites?"
- Next in thread: Berislav Lopac: "Re: OOP leads to lousy websites?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|