Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
617 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...