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

Tissue type field #96

Merged
merged 5 commits into from
Oct 14, 2019
Merged

Tissue type field #96

merged 5 commits into from
Oct 14, 2019

Conversation

SimNee
Copy link

@SimNee SimNee commented Oct 11, 2019

Added tissue type field and its test file. It passed travis and gradle as of now

@coveralls
Copy link

coveralls commented Oct 11, 2019

Coverage Status

Coverage increased (+0.4%) to 75.635% when pulling 9d15055 on tissuetype-field into 1179f90 on master.

} else {
for (int i = 0; i < tissuetypeValue.length; i++) {
try {
Integer tt = Integer.parseInt(tissuetypeValue[i]);

Choose a reason for hiding this comment

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

There is no check for whether the tissue types are numbers from 1-12

Choose a reason for hiding this comment

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

can you add check that all numbers is non duplication and from range 1-12.

Copy link
Author

Choose a reason for hiding this comment

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

Actually according to the link jiaying gave and google, there seems to be more than 12 types of tissue. But I cant really find a fixed number online on how manu types exactly. Should we just assume its 12?

Choose a reason for hiding this comment

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

I did some additional research. Apparently there are a lot more tissue types. We can stick to 12 tissues.

Copy link
Author

Choose a reason for hiding this comment

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

Ok noted. Will change by tonight. I can make to 20 actually since I think the total type is more than 20

Choose a reason for hiding this comment

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

just stick with 12 for simplicity. Thanks!

Choose a reason for hiding this comment

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

so just have a check if all number is <= 12 and there is non duplicate

Choose a reason for hiding this comment

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

so just have a check if all number is <= 12 and there is non duplicate

Choose a reason for hiding this comment

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

Can add comment that its > 12 types but we are limiting it for now. Perhaps add //TODO: comment

Copy link
Author

Choose a reason for hiding this comment

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

Ok noted

}

@Test
public void isValidTissuetype() {

Choose a reason for hiding this comment

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

Just wondering, if I have an input string "1, 2, 3, 4, 5, 6", would it count?

Copy link
Author

Choose a reason for hiding this comment

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

yes, line 38 tested it

Choose a reason for hiding this comment

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

I meant if the input string will accept the inputs separated by a comma and a space. Line 38 tests if the inputs are separated by commas.

assertFalse(Tissuetype.isValidTissuetype("1 2 3 4 5 6")); // spaces within tissuetype

// valid tissuetype
assertTrue(Tissuetype.isValidTissuetype("1,2,3,4,5,6")); // exactly 6 tissuetype

Choose a reason for hiding this comment

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

Could you include test cases for tissue types > 12? Eg 13, 14.

Copy link
Author

Choose a reason for hiding this comment

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

yes, line 45

Choose a reason for hiding this comment

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

Line 45 tests the toString() method, not the isValidTissueType() method. Could you add test cases which checks for numbers that are not accepted as valid tissue types?

Copy link
Author

Choose a reason for hiding this comment

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

yes done

Copy link

@C-likethis123 C-likethis123 left a comment

Choose a reason for hiding this comment

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

Good work! I've requested some changes.

@iskandarzulkarnaien
Copy link

iskandarzulkarnaien commented Oct 12, 2019

If the PR fixes a certain issue please tag it by adding fixes #issueNumber in the description

Copy link

@WilliamRyank WilliamRyank left a comment

Choose a reason for hiding this comment

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

LGTM

for (int i = 0; i < tissuetypeValue.length; i++) {
try {
Integer tt = Integer.parseInt(tissuetypeValue[i]);
if (tt > 12) {

Choose a reason for hiding this comment

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

How about a check for tt < 1?

Choose a reason for hiding this comment

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

Yes, please check for < 1. Can check together with > 12 in same line.

Copy link

@C-likethis123 C-likethis123 left a comment

Choose a reason for hiding this comment

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

Overall good job, do make the changes requested.

public final String value;

/**
* Constructs a {@code Bloodtype}.
*
* @param bloodtype A valid bloodtype.

Choose a reason for hiding this comment

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

Change to camelCase for all references of BloodType or bloodType ?

Choose a reason for hiding this comment

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

Ctrl + shift +R for find and replace

* Represents a Person's tissue type in ORGANice.
* Guarantees: immutable; is valid as declared in {@link #isValidTissuetype(String)}
*/
public class Tissuetype {

Choose a reason for hiding this comment

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

CamelCase here as well ?

String[] tissuetypeValue = test.split(",");
if (tissuetypeValue.length != 6 || isDuplicated(tissuetypeValue)) {
return false;
} else {

Choose a reason for hiding this comment

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

Can we drop the else block to reduce indentation by 1 level? What does the code style say about this?

for (int i = 0; i < tissuetypeValue.length; i++) {
try {
Integer tt = Integer.parseInt(tissuetypeValue[i]);
if (tt > 12) {

Choose a reason for hiding this comment

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

Yes, please check for < 1. Can check together with > 12 in same line.

/**
* Returns true if a given string array contains duplicate.
*/
public static boolean isDuplicated(String[] test) {

Choose a reason for hiding this comment

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

Perhaps hasDuplicates or containsDuplicates would be a better name

// invalid tissuetype
assertFalse(Tissuetype.isValidTissuetype("")); // empty string
assertFalse(Tissuetype.isValidTissuetype(" ")); // spaces only
assertFalse(Tissuetype.isValidTissuetype("a,b,c,d,e,f")); // wrong tissuetype

Choose a reason for hiding this comment

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

Perhaps would be better to say \\ tissue types must be Integers from 1..12. The dots are intentional btw. .. means range inclusive, ... means range exclusive

Copy link

@C-likethis123 C-likethis123 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@iskandarzulkarnaien iskandarzulkarnaien left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @SimNee & @WilliamRyank

@WilliamRyank WilliamRyank merged commit 8cf997f into master Oct 14, 2019
@iskandarzulkarnaien
Copy link

Added tissue type field and its test file. It passed travis and gradle as of now

In the future please use the issue description to describe the issue. Leave comments such as travis and gradle to a follow up comment. Thanks

@iskandarzulkarnaien
Copy link

Added tissue type field and its test file. It passed travis and gradle as of now

In the future please use the issue description to describe the issue. Leave comments such as travis and gradle to a follow up comment. Thanks

This is due to the fact that when the issue is referenced elsewhere, your description will be shown when people hover over the link

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.

5 participants