On 1/28/11 11:21 AM, Bernhard Schussek wrote:
Hi all,
I just had a lengthy conversation with Jordi and he somehow convinced
me of the benefits of reimplementing \NumberFormatter instead of
creating wrapper classes.
Arguments against my suggestion:
- If we create wrapper classes, we need an abstract factory with
different implementations returning either the wrappers or the fake
objects. Based on whether intl is loaded, the correct factory
implementation needs to be created and injected everywhere where we
need intl, which becomes messy very fast.
- We need to reimplement all the constants that are available in intl
and map them to the real intl constants (think associative array), or
else our code will break if the intl maintainers for some reason
decide to change their constant values. Lookups in this mapping need
to be done in every method that accepts constant values, which is
overhead again.
So I think there is a different solution:
We create fake implementations of the intl classes in the Locale
component (e.g. Symfony\Component\Locale\Stub\NumberFormatter). These
classes must have the same interface and public constants as their
intl counterparts. In the methods, we carefully have to throw
exceptions if any invalid combination of parameters is passed
(unsupported constant, unsupported locale, unsupported parameter etc.)
For the supported combinations of input parameters, our implementation
*must* fully comply to the intl implementation.
I suggest to make use of this fake implementation configurable (e.g.
fake_intl). If this configuration is set to true, we create the global
intl classes on the fly, inheriting our fake implementation
(\NumberFormatter<- Symfony\...\Stub\NumberFormatter). Setting the
configuration to true is disallowed if the intl extension is
available.
What do you think?
Excellent. I think this is a much better approach.
Fabien
Bernhard
--
Software Architect& Engineer
Blog: http://webmozarts.com
Twitter: http://twitter.com/webmozart
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en