On Tue, Nov 15, 2011 at 18:25, Vincent Massol <vincent(a)massol.net> wrote:
On Nov 15, 2011, at 5:29 PM, Denis Gervalle wrote:
On Tue, Nov 15, 2011 at 17:11, Vincent Massol
<vincent(a)massol.net>
wrote:
>
> On Nov 15, 2011, at 5:03 PM, Denis Gervalle wrote:
>
>> Hi Devs,
>>
>> The implementation of the immutable version of reference is almost
ready
>> now. It introduce the parameters on
reference as suggested, but we now
> have
>> a discussion on how the constructors of "typed" entity reference
should
> be.
>>
>> My initial dev was to provide constructor like:
>
> you're missing something here :)
>
>> But Vincent have different vision of this, here its comment extracted
> from
>
> I don't have a different vision. It's just that you limited your
proposal
> to just Locale which clearly isn't good
enough.
>
>> GitHub (
>>
>
https://github.com/xwiki/xwiki-platform/commit/cea424914f40ce924afbc49b3159…
> )
>> :
>>
>> My proposal was:
>>> - generic params in EntityReference
>>> - helpers methods for get/setLocale and get/setVersion in
> DocumentReference
>>>
>>> Now the fact that we're making the refs immutable changed this since
> it's
>>> no longer possible.
>>>
>>> I don't think multiplying the constructor signatures is a good idea.
>>>
>>> We could either have:
>>>
>>> public DocumentReference(String wikiName, List spaceNames, String
>>> pageName, Map<String, Object> parameters)
>>>
>>> or
>>>
>>> public DocumentReference(String wikiName, List spaceNames, String
>>> pageName, Pair<String, Object>... parameters)
>>>
>>> where Pair is
>>>
>
http://commons.apache.org/lang/api-3.0-beta/org/apache/commons/lang3/Pair.h…
>>>
>>> Maybe this needs some discussion on the devs list rather than here to
> make
>>> sure everyone sees it?
>>>
>>
>> I am myself not really happy with that since I dislike the idea that
>> parameter are generic on "typed" references.
>> Do not like either the idea to provide keys for creating a Map or
Pairs,
since the implementation details that use Map should
not be so exposed
IMO.
There should not be so much parameter on a single "typed" reference,
I don't understand this sentence.
The Map is <String, Object>.
I would means that this should not cause so many additional constructors,
if we list them individually.
So your have not the same vision then I have :)
See below.
and
these should be easy to provide. Creating Maps in java is not fun in
syntax
for that IMO, and is far too open.
Sure but the goal here is not to redo java…
Not my goals, just want to be explicit and easy to use.
>
>> I had propose using overloaded constructor like
>>
>> public DocumentReference(String wikiName, List<String> spaceNames,
String
>> pageName, Locale locale)
>
> Again, this doesn't work. It only works for a **single** parameter. It
> doesn't work for multiple parameters. How do you specify the Locale or
some
unknown
String param?
I simply provide the need constructor, no more.
If you say this then you say that we don't need generic parameters for
References which is what started the discussion…
Also what you say is not correct at all since we already know we need
Version which you didn't put.
Not yet implemented. Isn't this your proposal initially ?... my needs is
Locale for now.
Last, it means passing null to the constuctors when you don't use the
parameters which is really really bad IMO or you'll need to define lots of
various constructors which increase exponentially with the number of
parameters we support.
Probably, but personally I was not expect so many parameter on a given
"typed" reference.
However this won't even work since you won't be able to support adding new
parameters. Users of the Reference system will need to modify its source if
they wish to add a new parameter which again goes against the initial
proposal.
Not sure what you means here.
>> or if something more flexible should be
used
>>
>> public DocumentReference(String wikiName, List<String> spaceNames,
String
>> pageName, Object... parameters)
>>
>> where parameters is later interpreted based on object type and limited
to
those used for a given typed reference.
This doesn't work. If I have 2 parameters of type String, how do you map
them automatically?
I suggest not to have loosely typed parameters, but strong one, like
Locale
and Version.
I'm a big big big -1 on this.
There's no reason to create a fake String when all you need is a string.
Same for int, long, Number, etc.
Same for also if you want to have several Locales or several Versions.
There is for me good reason not to use String, we have seen what happen
with String, and this why we now use Reference.
Also the
goal is to have unknown parameters so how can you do a mapping
for something unknown? :)
That is clearly not my goal, why do you want unknown parameters on
Document
Reference ?
Maybe this is where we don't agree. This is the original idea: to have a
set of "unknown" parameters for extensibility (from the POV of the
Reference of course, from the POV of XWiki they are not unknown obviously
;)).
Entity Reference, which is the base of any reference have and support the
unknown references that are well know from typed references. There is
almost nothing except typing at the document reference level.
This means that it's up to the users of the
References to decide what
parameters to put and it's up to the consumers to decide what parameters to
support.
Agreed at the Entity Reference level, but for me a Document Reference
should not have arbitrary parameters. What is the UC for this ? Since all
parameters change the identity of a reference, I do not understand what you
expect from arbitrary parameters except more issues.
It seems to me your vision is to:
* Not support arbitrary parameters
for typed references ( like DocumentReference) but EntityReference does
not have any a particular knowledge.
* Only support Version and Locale
currently for DocumentReference, but what else do you expect here ? I means
that I do not expect to have
to much parameters for a given typed reference for not supporting them in
constructors has individual arguments.
* Provide 3 constructors, one where there's no
Locale no Version, one with
Locale no version and one with Version on Locale
true, practical, documentary, and clearly what we really need right now.
Whereas my vision is:
* Support arbitrary parameters for extensibility (like
a URL if you prefer
which support arbitrary parameters)
* Have some "well-known" parameters so that xwiki code that users
References know what they can put as reference parameters and what they can
extract from XWiki parameters.
How could well-know it could be ? Do you means that you will later check
the maps to validate the list of key allowed in a document ? I am not
against this, but I am against forcing the creation of a map just to
specify a language or a version.
Thanks
-Vincent
> Thanks
> -Vincent
>
>> Here Vincent comments on this:
>>
>>> The automatic mapping idea seems a bad idea to me (too magic and
doesn't
>>> work in a lot of cases).
>>
>>
>> Maybe some of you have an even better idea ?
>>
>> Denis
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Denis Gervalle
SOFTEC sa - CEO
eGuilde sarl - CTO