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

Remove dcc common and dcc id dependency#503 #574

Merged
merged 5 commits into from
Jan 8, 2020

Conversation

KevinFHartmann
Copy link
Contributor

Now compiles, builds, and passes make test-*.

Copy link
Contributor

@rtisma rtisma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see, i am allergic to string literals. If the same literal gets repeated more than once, it should instead be referenced as a variable. I left a few comments for the Splitters and Joiners class that needs to be made, but there are several other lines that need similar fixing and i didnt comment on them so that this review isnt riddled with identical comments.

<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.1</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this version definition into the <dependencyManagement> block of the root pom.xml. If this dependency is only used in song-server, then rip out the dependency from the dependencyManagement section and put it here. Also, use the version variable like ${jaxb.version}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String constants are a valid part of the Java language. Don't be so afraid of them!

If we expect the definition of a constant to ever change, then YES, by all means, we should use a name rather than an inline value.

OBJECT_NAME_DELIMITER might change. NEWLINE might change (based upon different operating systems idea of what a new line should be).

But the definition of a something like COMMA should never change, and if it does, it's confusing.

All we accomplish by separating the definition of the constant from the code in this case is forcing the developer to do extra work to double check that COMMA is defined as ",".

Copy link
Contributor

@rtisma rtisma Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i find that string constants are harder to read and make it hard to search for via the IDE. by using COMMA, you can inspect its usage easily. Regarding double checking, for something that sensitive, there should be tests in place that ensure it functions as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. How is searching for "," any harder than searching for COMMA? If anything, it should be easier, since it's two less characters to type. :-)

There should always be tests. That doesn't mean that the code does what you think it does when you read it.:-)

But for consistency, I'll make you happy. :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@@ -82,7 +81,7 @@
@ApiParam(value = "Non-empty comma separated list of analysis states to filter by")
@RequestParam(value = "analysisStates", defaultValue = "PUBLISHED", required = false)
String analysisStates) {
return analysisService.getAnalysis(studyId, ImmutableSet.copyOf(COMMA.split(analysisStates)));
return analysisService.getAnalysis(studyId, ImmutableSet.copyOf(",".split(analysisStates)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a Splitters class with a no args constructor, that contains:
public static final Splitter COMMA = Splitter.on(",");
and likewise for any other splits.

@@ -59,7 +58,7 @@
public static final String DEFAULT_SORT_VARIABLE = VERSION;
public static final Direction DEFAULT_SORT_ORDER = DESC;

private static final String ALLOWED_SORT_VARIABLES = COMMA.join(VERSION, NAME);
private static final String ALLOWED_SORT_VARIABLES = VERSION + "," + NAME;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a no args constuctor Joiners class that contains the following:
public static final Joiner COMMA = Joiner.on(",");
likewise for any other characters to join on

@@ -172,7 +171,7 @@ private static String errorResponseBody(
}

private static List<String> getFullStackTraceList(Throwable t) {
return NEWLINE.splitToList(getStackTraceAsString(t)).stream()
return stream(getStackTraceAsString(t).split("\n"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline splitter

@@ -415,7 +415,7 @@ private void checkMissingFiles(String analysisId, List<FileEntity> files) {
"The following storage objectIds must be uploaded to the storage server before the "
+ "analysisId %s can be published: %s",
analysisId,
COMMA.join(missingFileIds));
join(",", missingFileIds));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Joiners.COMMA

Copy link
Contributor

@rtisma rtisma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, there are conflicts with the branch

… for commonly used string constants.

Change: Now use the Separators enum and avoid the use of String constants.
import java.util.List;

/** Joiners and Splitters for commonly used separators. */
public enum Separators {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it!

@KevinFHartmann KevinFHartmann merged commit a7c4e57 into develop Jan 8, 2020
@KevinFHartmann KevinFHartmann deleted the Remove_dcc-common_and_dcc-id_dependency#503 branch January 8, 2020 15:36
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.

2 participants