[xwiki-devs] [VOTE][Model] Do we need to change Entity Reference Factory to some other name? And which one?
Hi, This is the current interface: public interface EntityReferenceFactory<T> { /** * @param entityReferenceRepresentation the representation of an entity reference (eg as a String) * @param type the type of the Entity (Document, Space, Attachment, Wiki, etc) to extract from the source * @return the resolved reference as an Object */ EntityReference createEntityReference(T entityReferenceRepresentation, EntityType type); } Now we have 2 different implementations: - one for which T = String - one for which T = EntityReference (our normalizer) In term of usage this means: EntityReference ref = factory.createEntityReference("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = factory.createEntityReference(documentReference, EntityType.DOCUMENT); The last example is used to normalize the passed reference, convert it into the type specified by the second parameter, filling the blanks. I feel that Factory is no longer an appropriate name, especially for the second use case. WDYT? IMO a better name would be Resolver, Normalizer, or Converter. Any other better name? (I haven't put Parser since I don't believe it's correct). Examples: EntityReference ref = resolver.resolve("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = resolver.resolve(documentReference, EntityType.DOCUMENT); EntityReference ref = normalizer.normalize("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = normalizer.normalize(documentReference, EntityType.DOCUMENT); EntityReference ref = converter.convert("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = converter.convert(documentReference, EntityType.DOCUMENT); It's quite a lot of work to change what I have put but since this is an important API we need to be sure of what we want since we won't be able to change it later on. I'm +1 for Resolver. WDYT? Thanks -Vincent
On Wed, Jan 6, 2010 at 15:21, Vincent Massol <[email protected]> wrote:
Hi,
This is the current interface:
public interface EntityReferenceFactory<T> { /** * @param entityReferenceRepresentation the representation of an entity reference (eg as a String) * @param type the type of the Entity (Document, Space, Attachment, Wiki, etc) to extract from the source * @return the resolved reference as an Object */ EntityReference createEntityReference(T entityReferenceRepresentation, EntityType type); }
Now we have 2 different implementations: - one for which T = String - one for which T = EntityReference (our normalizer)
In term of usage this means:
EntityReference ref = factory.createEntityReference("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = factory.createEntityReference(documentReference, EntityType.DOCUMENT);
The last example is used to normalize the passed reference, convert it into the type specified by the second parameter, filling the blanks.
I feel that Factory is no longer an appropriate name, especially for the second use case. WDYT?
IMO a better name would be Resolver, Normalizer, or Converter. Any other better name? (I haven't put Parser since I don't believe it's correct).
Examples:
EntityReference ref = resolver.resolve("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = resolver.resolve(documentReference, EntityType.DOCUMENT);
EntityReference ref = normalizer.normalize("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = normalizer.normalize(documentReference, EntityType.DOCUMENT);
EntityReference ref = converter.convert("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = converter.convert(documentReference, EntityType.DOCUMENT);
It's quite a lot of work to change what I have put but since this is an important API we need to be sure of what we want since we won't be able to change it later on.
I'm +1 for Resolver.
+1 for Resolver
WDYT?
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Wed, Jan 6, 2010 at 3:27 PM, Thomas Mortagne <[email protected]>wrote:
On Wed, Jan 6, 2010 at 15:21, Vincent Massol <[email protected]> wrote:
Hi,
This is the current interface:
public interface EntityReferenceFactory<T> { /** * @param entityReferenceRepresentation the representation of an entity reference (eg as a String) * @param type the type of the Entity (Document, Space, Attachment, Wiki, etc) to extract from the source * @return the resolved reference as an Object */ EntityReference createEntityReference(T entityReferenceRepresentation, EntityType type); }
Now we have 2 different implementations: - one for which T = String - one for which T = EntityReference (our normalizer)
In term of usage this means:
EntityReference ref = factory.createEntityReference("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = factory.createEntityReference(documentReference, EntityType.DOCUMENT);
The last example is used to normalize the passed reference, convert it into the type specified by the second parameter, filling the blanks.
I feel that Factory is no longer an appropriate name, especially for the second use case. WDYT?
IMO a better name would be Resolver, Normalizer, or Converter. Any other better name? (I haven't put Parser since I don't believe it's correct).
Examples:
EntityReference ref = resolver.resolve("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = resolver.resolve(documentReference, EntityType.DOCUMENT);
EntityReference ref = normalizer.normalize("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = normalizer.normalize(documentReference, EntityType.DOCUMENT);
EntityReference ref = converter.convert("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = converter.convert(documentReference, EntityType.DOCUMENT);
It's quite a lot of work to change what I have put but since this is an important API we need to be sure of what we want since we won't be able to change it later on.
I'm +1 for Resolver.
+1 for Resolver
+1 for resolver also... normalizer is a bit too much abstract IMO
WDYT?
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Vincent, +1 for Resolver sounds good enough for me. Happy coding, Anca On 01/06/2010 04:21 PM, Vincent Massol wrote:
Hi,
This is the current interface:
public interface EntityReferenceFactory<T> { /** * @param entityReferenceRepresentation the representation of an entity reference (eg as a String) * @param type the type of the Entity (Document, Space, Attachment, Wiki, etc) to extract from the source * @return the resolved reference as an Object */ EntityReference createEntityReference(T entityReferenceRepresentation, EntityType type); }
Now we have 2 different implementations: - one for which T = String - one for which T = EntityReference (our normalizer)
In term of usage this means:
EntityReference ref = factory.createEntityReference("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = factory.createEntityReference(documentReference, EntityType.DOCUMENT);
The last example is used to normalize the passed reference, convert it into the type specified by the second parameter, filling the blanks.
I feel that Factory is no longer an appropriate name, especially for the second use case. WDYT?
IMO a better name would be Resolver, Normalizer, or Converter. Any other better name? (I haven't put Parser since I don't believe it's correct).
Examples:
EntityReference ref = resolver.resolve("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = resolver.resolve(documentReference, EntityType.DOCUMENT);
EntityReference ref = normalizer.normalize("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = normalizer.normalize(documentReference, EntityType.DOCUMENT);
EntityReference ref = converter.convert("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = converter.convert(documentReference, EntityType.DOCUMENT);
It's quite a lot of work to change what I have put but since this is an important API we need to be sure of what we want since we won't be able to change it later on.
I'm +1 for Resolver.
WDYT?
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Vincent Massol wrote:
Hi,
This is the current interface:
public interface EntityReferenceFactory<T> { /** * @param entityReferenceRepresentation the representation of an entity reference (eg as a String) * @param type the type of the Entity (Document, Space, Attachment, Wiki, etc) to extract from the source * @return the resolved reference as an Object */ EntityReference createEntityReference(T entityReferenceRepresentation, EntityType type); }
Now we have 2 different implementations: - one for which T = String - one for which T = EntityReference (our normalizer)
In term of usage this means:
EntityReference ref = factory.createEntityReference("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = factory.createEntityReference(documentReference, EntityType.DOCUMENT);
The last example is used to normalize the passed reference, convert it into the type specified by the second parameter, filling the blanks.
I feel that Factory is no longer an appropriate name, especially for the second use case. WDYT?
IMO a better name would be Resolver, Normalizer, or Converter. Any other better name? (I haven't put Parser since I don't believe it's correct).
Examples:
EntityReference ref = resolver.resolve("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = resolver.resolve(documentReference, EntityType.DOCUMENT);
+0 for Resolver. I find the unification between the factory and the normalizer a bit unnatural. Thanks, Marius
EntityReference ref = normalizer.normalize("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = normalizer.normalize(documentReference, EntityType.DOCUMENT);
EntityReference ref = converter.convert("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = converter.convert(documentReference, EntityType.DOCUMENT);
It's quite a lot of work to change what I have put but since this is an important API we need to be sure of what we want since we won't be able to change it later on.
I'm +1 for Resolver.
WDYT?
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Jan 6, 2010, at 5:19 PM, Marius Dumitru Florea wrote:
Vincent Massol wrote:
Hi,
This is the current interface:
public interface EntityReferenceFactory<T> { /** * @param entityReferenceRepresentation the representation of an entity reference (eg as a String) * @param type the type of the Entity (Document, Space, Attachment, Wiki, etc) to extract from the source * @return the resolved reference as an Object */ EntityReference createEntityReference(T entityReferenceRepresentation, EntityType type); }
Now we have 2 different implementations: - one for which T = String - one for which T = EntityReference (our normalizer)
In term of usage this means:
EntityReference ref = factory.createEntityReference("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = factory.createEntityReference(documentReference, EntityType.DOCUMENT);
The last example is used to normalize the passed reference, convert it into the type specified by the second parameter, filling the blanks.
I feel that Factory is no longer an appropriate name, especially for the second use case. WDYT?
IMO a better name would be Resolver, Normalizer, or Converter. Any other better name? (I haven't put Parser since I don't believe it's correct).
Examples:
EntityReference ref = resolver.resolve("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = resolver.resolve(documentReference, EntityType.DOCUMENT);
+0 for Resolver. I find the unification between the factory and the normalizer a bit unnatural.
The Factory is not really a factory since: 1) It takes the definition in param. It's more a Parser or a Converter/Resolver. 2) A Factory is there to return an interface and have different implementations returning different implementing classes for the return interface. See http://en.wikipedia.org/wiki/Factory_method_pattern Thanks -Vincent
Thanks, Marius
EntityReference ref = normalizer.normalize("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = normalizer.normalize(documentReference, EntityType.DOCUMENT);
EntityReference ref = converter.convert("wiki:space.page", EntityType.DOCUMENT); EntityReference ref = converter.convert(documentReference, EntityType.DOCUMENT);
It's quite a lot of work to change what I have put but since this is an important API we need to be sure of what we want since we won't be able to change it later on.
I'm +1 for Resolver.
WDYT?
Thanks -Vincent
participants (5)
-
Anca Luca -
Marius Dumitru Florea -
Pascal Voitot -
Thomas Mortagne -
Vincent Massol