Saturday, 15 January 2011

java - naming methods with different return types but the same functionality -



java - naming methods with different return types but the same functionality -

i'm talking java, concept apply other languages --

we have 2 methods on same class have same basic functionality, provide different homecoming types. both methods things, 1 gets iterable can provide access things, , 1 gets collection includes things.

we know cannot (because won't compile):

iterable getthings() collection getthings()

so, have thoughts how name methods? seems easy prepare say:

iterable getiterableofthings collection getcollectionofthings

however, verbose , perhaps not best solution. question i'm asking imply our organization/coding approach somehow off mark, or valid question?

has else dealt scenario?

how about:

iterable getiterator(); collection getthings();

java

No comments:

Post a Comment