Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More generics in Dataverse and SAVFileReader classes #931

Closed
wants to merge 4 commits into from

Conversation

bencomp
Copy link
Contributor

@bencomp bencomp commented Sep 22, 2014

Related to #775 - Eclipse found a few instantiations of ArrayLists without types. Builds on my machine :)

@landreev
Copy link
Contributor

Re: SAVFileReader.java - that one is on my list of classes to fully rework and clean up.
These changes, with generic ArrayList instantiations, definitely look ok; as in, they should not hurt...
But, a stupid question perhaps - is this really necessary?
It's interesting that, apparently, Eclipse and Netbeans seem to have different standards of what should be considered "clean" code.
Not only is Netbeans NOT complaining about the lines above; it actually complains whenever I do something like

        List<SummaryStatistic> testlist = new ArrayList<SummaryStatistic>();
  • it shows a hint implying that the type declaration is "redundant".
    I'm definitely willing to make any changes that would make our code cleaner and more standard; just a little confused as to what the rules are.

@bencomp
Copy link
Contributor Author

bencomp commented Sep 22, 2014

Interesting indeed. I didn't know the answer to what the 'correct' way is - I still don't know what is best, let alone that I should tell you what to do :) (@pdurbin suggested code style checker plugins for Jenkins in #775)

According to someone on StackOverflow, there is a reason for Java 7's diamond operator (e.g. ArrayList<>()) when you could also use the raw type (ArrayList()): it enforces checking of correct application of generic typing. I think that to have the same strictness in Java 5 or 6 you do need the fully typed type.

Not to be pedantic or annoying, but What is a raw type and why shouldn't we use it? gives a nice overview of reasons to not use raw types.

@pdurbin
Copy link
Member

pdurbin commented Sep 22, 2014

I always let NetBeans insert the diamond operator since we are requiring Java 7 or higher.

Using Eclipse I added type arguments to many variables and parameters. A few could not be changed because both `Dataverse`s and `Dataset`s are added to a raw `List`, e.g. in `DataversePage.getContents()`. I added a FIXME there, but the same problem can be observed elsewhere. I couldn't find uses of that code.

I also let Eclipse remove unused imports, because they are easily fixed and readded if necessary.
@bencomp
Copy link
Contributor Author

bencomp commented Sep 23, 2014

Let me create a different smaller pull request, as I discussed with @pdurbin on IRC. I now used NetBeans to refactor the full type arguments into diamonds (e.g. = new ArrayList<String>(); -> = new ArrayList<>();).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants