rigelhope / omnidroid

Automatically exported from code.google.com/p/omnidroid
Apache License 2.0
0 stars 0 forks source link

Methods should take/return List, Map, etc. instead of ArrayList, HashMap, etc. #36

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Check out AGParser.java readEvents(). The return type is
ArrayList<HashMap<String, String>>. This exposes the implementation of the
List to the user of the method. It's preferable to return a
List<Map<String, String>> because the user shouldn't care that it's a
HashMap or an ArrayList specifically.

Throughout the project, most methods shouldn't be returning implementation
classes for Collections, but instead the more general List, Set, and Map.
Refactor code where necessary to fix this.

Some eclipse advice: Make copious use of selecting the method name of the
method to be refactored, and right clicking, selecting Refactor --> Change
Method Signature and making changes that way. 

Also use References --> In Workspace to find all users of the methods.

Original issue reported on code.google.com by ksjohnson3 on 15 Jun 2009 at 6:41

GoogleCodeExporter commented 8 years ago
Hi Kai,

According to the following link, it is advisable to do just this for 
performance 
reason unless we are working on public API.

http://developer.android.com/guide/practices/design/performance.html#prefer_virt
ual

I don't know if you think above would be considered a public API but just 
wanted to 
point out why original developers might have selected the given route.

Original comment by akshah...@gmail.com on 15 Jun 2009 at 6:45

GoogleCodeExporter commented 8 years ago
Ah, well that pretty much settles it. Thanks for pointing that out. We should
probably link to any Android-specific best practices we expect code to follow 
for use
in code reviews.

If no one has any objections, I'll close out this issue as "won't fix."

Original comment by ksjohnson3 on 15 Jun 2009 at 7:01

GoogleCodeExporter commented 8 years ago

Original comment by ksjohnson3 on 15 Jun 2009 at 9:34