Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
546 views
in Technique[技术] by (71.8m points)

naming conventions - How to name a class that moves through the data structure in no particular order

I have a data structure with an underlying immutable undirected graph. Separately, I have another class that handles moving to the vertices, adjacent to the current vertex. Current vertex can be set to any vertex in a graph.

The related (but unsatisfying) name options I came up with include:

  • Traverser
  • Iterator
  • Cursor (Scrollable Cursor)

Traverser does not fit, because it implies visiting every single vertex of the graph, which is not required in my case. Also, the term "traverse" is used way more frequently in relation to the trees (i.e. the tree traversal), so it might confuse the code readers as they can assume underlying tree (which is a special case of a graph).

Iterator, seemingly, doesn't fit as well, since it also implies traversal of a container (i.e. visiting each vertex). Furthermore, Wikipedia page states that "There must be some way to determine when the iterator has exhausted all of the elements in the container", which never happens with my class. As a side-note, I am aware that some languages and frameworks use the term "Infinite Iterator" that can apply in theory but is somewhat confusing.

Cursor as in Database Cursor. The definition of Scrollable Cursor is the one that fits the best so far, but I wish I found something less specific to databases, more familiar, shorter, or related to the graph terminology.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...