Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Enumeration or instance methods  RSS feed

 
Robert Scheffer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have coded using both implements Enumerations as well as create instance methods that do the same thing and have yet to figure which way is better. I would guess that implementing Enumeration would be better if you had client code that called for such (As it perhaps should or maybe better some other Collections interface). But what are the costs, if any, on the object creation for Enumeration vs. just having instance methods that would do the same?
Furthermore, since Enumeration is now becoming obsolete because of the Collections interface, which interface will now be the norm for doing such a task? Does this mean we will skip implementing a Collections interface and stick with our own? I hope not.
 
Jim Baiter
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The interface that replaces Enumeration is the Iterator.
The API doc says that new implementations should consider
using the Iterator over the Enumeration. I think in terms
of writing your own methods to accomplish the same thing as
Enumeration/Iterator, I would strongly suspect the library
methods will be as fast or faster.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!