[ 
https://issues.apache.org/jira/browse/TINKERPOP-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17269675#comment-17269675
 ] 

Christopher Smith commented on TINKERPOP-2502:
----------------------------------------------

Putting on my API-client hat, "that's your job!"

My thinking is going like this: The purpose of an interface is to support 
multiple implementations. Imagine we have a {{TraversalStartSteps}} interface 
defining our quad.

- {{GraphTraversal implements TraversalStartSteps}} by simply doing the exact 
thing it already does, appending the new {{AddVertexStep}} to an ongoing 
traversal.
- {{__.start()}} returns a {{GraphTraversal}}, so it's covered.
- {{GraphTraversalSource implements TraversalStartSteps}} by doing the same 
thing it already does, which is to clone stuff _and add the "start steps" 
necessary to get it going_.

As far as I can tell, by introducing {{TraversalStartSteps}}, client code can 
now initiate calling whichever of them regardless of whether they're initiating 
a blank traversal, appending to an existing one, or starting an anonymous 
subtraversal, and I don't think any further modification to any of the existing 
API is required, only creating this minimal superinterface.


> Consistent start API for anonymous and regular traversals
> ---------------------------------------------------------
>
>                 Key: TINKERPOP-2502
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2502
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.4.9
>            Reporter: Christopher Smith
>            Priority: Minor
>
> I am writing a graph-based application and am taking advantage of the 
> method-based nature of Gremlin to librarify some of my common usage patterns. 
> However, I'm encountering a frustrating problem where I frequently need to be 
> able to attach the same traversal steps to either a real 
> {{GraphTraversalSource}} or an anonymous traversal (usually for some nested 
> reason like a coalesced conditional insert).
> The methods on {{__}} are mostly static, but I can call {{__.start()}} to 
> obtain a live {{GraphTraversal}} object and then proceed from there (invoking 
> {{GraphTraversal#addV}}, for example). {{GraphTraversalSource}}, however, 
> requires me to invoke the method {{GraphTraversalSource#addV}} to get 
> started, and there's no common base type. I think I could theoretically use 
> something like {{inject()}}, but that seems particularly odd.
> It would be helpful to either have both {{GraphTraversal}} and 
> {{GraphTraversalSource}} implement a common interface holding the "start 
> opcodes" or to have a {{GraphTraversalSource#start()}} method that could be 
> used to obtain a "blank" traversal.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to