« Return to Thread: Debugging/deciphering library methods
On Sep 27, 2007, at 4:02 PM, Ryan Boyd wrote:
>> In order not to break backwards compatibility, we could use
>> introspection to choose the correct behavior. If an instance of
>> Zend_Gdata_App_Extension is detected, we'd use the current behavior
>> (just set the property to point to the provided object). For all
>> other types, we'd use the new behavior (create a new instance of the
>> property's model and initialize it with the provided data).
>
> This is the reason I recommended appending the attribute name with
> Value when an option like this is available. I don't think we can
> change the normal setters, because people will have no idea what's
> going to come out of the getter.
>
> so, I call $entry->title = 'foo'
> and then I get $entry->title... should that be an
> Zend_Gdata_App_Extension_Title, or just the string 'title'.
It would be an instance of Zend_Gdata_App_Extension_Title.
However, for most operations the user can pretend it's the string
'title'. When it gets passed to something that is expecting a string,
__toString() should get called assuming they're using PHP 5 (which is
supposed to be a requirement for ZF).
> I think appending the attribute names with 'Value' will allow you
> to use either option.
It would. However, it feels like we'd be duplicating code. Wouldn't
'$entry->titleValue' be identical to calling '$entry->title-
>__toString()', or '(string) $entry->title' on PHP 5?
>> Extensions which take several parameters, such as
>> Zend_Gdata_Extension_When does, will be tricky. Unfortunately PHP
>> doesn't allow method overloading. I can think of a way to hack this
>> in using optional parameters ($data, $startTime = null, $endTime =
>> null, ... -- where $data could be either an Extension object or
>> $valueString), but I'd really like to avoid doing that. Any better
>> thoughts? Or should we just not implement a shortcut to instantiate
>> these objects?
>
> I think my first step would only be to allow these Value
> attributes for things that either have only 1 value to deal with,
> or things that have multiple values, but only 1 is used 95% of time.
>
> Then we could follow up with optional ones if we want, but the goal
> for this was to cover the largest use cases.
Sounds good to me.
--
Trevor Johns
http://tjohns.net
« Return to Thread: Debugging/deciphering library methods
| Free embeddable forum powered by Nabble | Forum Help |