ClassMethods hydrator default behavior

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ClassMethods hydrator default behavior

Adam Lundrigan
Rob Allen (Akrabat) and Gary Hockin (Spabby) and I were discussing the ClassMethods hydrator on IRC this morning.  The consensus is that the default behavior - assuming that array keys are camelCased - does not represent the most common use case, and combined with the naming of the flag variable ($useCamelCase) could be confusing for end-users.  I've set up two branches with possible fixes:  

  1. Change the intent of the constructor argument from negative to positive:
    https://github.com/adamlundrigan/zf2/compare/hotfix/classmethods-hydrator-default-to-underscore
    (a value of true would enable underscored keys, instead of false as it is now)

  2. Change the default value of the flag, and rename the variable to camelCaseArrayKeys for improved clarity
    https://github.com/adamlundrigan/zf2/compare/hotfix/classmethods-hydrator-default-to-underscore-bcflag
    ( a value of false would enable underscored keys, same as current behavior)

Personally, I prefer the first option as the positive tense of the flag make me happier....guess i'm just that kind of person ;)
Unfortunately, that breaks all current uses of ClassMethods hydrator as the default behavior has changed AND the intent of the flag is now flipped

The second option just changes the default behavior, so only those not supplying an argument to ClassMethods constructor are affected.

Thoughts?

--
Adam Lundrigan, B.Sc, ZCE
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: ClassMethods hydrator default behavior

Sascha-Oliver Prolic
2012/7/6 Adam Lundrigan <[hidden email]>:

> Rob Allen (Akrabat) and Gary Hockin (Spabby) and I were discussing the
> ClassMethods hydrator on IRC this morning.  The consensus is that the
> default behavior - assuming that array keys are camelCased - does not
> represent the most common use case, and combined with the naming of the flag
> variable ($useCamelCase) could be confusing for end-users.  I've set up two
> branches with possible fixes:
>
> Change the intent of the constructor argument from negative to positive:
> https://github.com/adamlundrigan/zf2/compare/hotfix/classmethods-hydrator-default-to-underscore
> (a value of true would enable underscored keys, instead of false as it is
> now)
>
> Change the default value of the flag, and rename the variable to
> camelCaseArrayKeys for improved clarity
> https://github.com/adamlundrigan/zf2/compare/hotfix/classmethods-hydrator-default-to-underscore-bcflag
> ( a value of false would enable underscored keys, same as current behavior)
>
>
> Personally, I prefer the first option as the positive tense of the flag make
> me happier....guess i'm just that kind of person ;)
> Unfortunately, that breaks all current uses of ClassMethods hydrator as the
> default behavior has changed AND the intent of the flag is now flipped
>
> The second option just changes the default behavior, so only those not
> supplying an argument to ClassMethods constructor are affected.
>
> Thoughts?
>
> --
> Adam Lundrigan, B.Sc, ZCE
> [hidden email]

I am +1 on this.
Regards

Sascha

--
Sascha-Oliver Prolic