TEAMMATES / teammates

This is the project website for the TEAMMATES feedback management tool for education
https://teammatesv4.appspot.com/
GNU General Public License v2.0
1.67k stars 3.3k forks source link

Java: Use Java 8 map.putIfAbsent and map.computeIfAbsent #8215

Closed wkurniawan07 closed 5 years ago

wkurniawan07 commented 6 years ago

Context: Someone wants to add a key-value pair to a map if the key-value pair does not exist.

Pre-Java 8:

if (!map.containsKey(key)) {
    map.put(key, value);
}

Java 8:

// If value is independent of key
map.putIfAbsent(key, value);

// If value is dependent of key
map.computeIfAbsent(key, key -> process(key));

For this one there are more than 20 places. Have to fix no less than 20 to qualify for a valid PR.

wenmogu commented 6 years ago

i can take this!

whipermr5 commented 6 years ago

Effort tracker, to be updated as each PR is merged:

PR Effort
#8226 4
mau0727 commented 6 years ago

Hello, I was looking into #8226. So is this considered resolved now ?

wkurniawan07 commented 6 years ago

@mau0727 no; there are still quite a lot of places that can benefit from putIfAbsent and computeIfAbsent, although they are admittedly harder to find than the ones already resolved in #8226.

gthd commented 6 years ago

I would really like to search and fix the remaining.

kathandp98 commented 6 years ago

I am a beginner, and I want to contribute to open source in java. I found this project interesting. Can someone suggest me where to start within this project and contribute? Thank you.

wenmogu commented 6 years ago

Hi @kathandp98 thx for wanting to contribute. I noticed that you have not introduced yourself to our contributor community yet:) I suggest that you can take a look at this document if you just started with this project. This document will give you a step-by-step guide on how to start as a contributor.

If you have done all the steps required in that documentation, you can start contributing to issues labelled with the blue tag d.FirstTimers. Those issues are mostly about replacement of code (just like this one) or editing some other minor mistakes within the codebase. Hope you enjoy this project.

whipermr5 commented 6 years ago

@wenmogu The self-introduction is no longer a requirement as of b8b73c189237a45de9e200d72e28859003f7c865 (#8602). But yes, that document is an excellent place to start 👍

kathandp98 commented 6 years ago

@wenmogu and @whipermr5 .Thanks for the reply. I will follow up the steps, and again if I will have doubts, I will post the comment. i will try my best to learn and contribute.

pedrolarben commented 6 years ago

Hi, I want to contribute to the project and I have been working on this issue. I have look to the whole code and I have found just 6 pieces of code where I can use .putIfAbsent, .computeIfAbsent. or .computeIfPresent. Should I do a Pull Request with these changes?

wenmogu commented 6 years ago

@pedrolarben yes sure. There r a lot of places for change. Just make sure what you find is not something in the ongoing PR for this issue :)

pedrolarben commented 6 years ago

@wenmogu cool. I'm going to create a PR with different changes of the ongoing PR :)

JonathanGin52 commented 6 years ago

Hey, I am also new to opensource projects and would love to contribute! Is this issue resolved?

wenmogu commented 6 years ago

Hello @JonathanGin52 welcome to TEAMMATES :) yep this issue is almost resolved, you can try your hand on other first timer issues

JonathanGin52 commented 6 years ago

@wenmogu Thanks for the greeting 😄, I'll be sure to check out the other issues

miderleta commented 6 years ago

Hi, Is this issue resolved. I would like to help as well.

prab2112 commented 6 years ago

Is this issue resolved? I would like to help as well.

reeshabhranjan commented 5 years ago

Has this issue resolved by now?