Skip to content

Conversation

@rimikadhara67
Copy link
Collaborator

No description provided.

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
// Get the value entered in the form.
String clientName = request.getParameter("clientName");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since clientName and clientPassword are used a few times in this class you can make them static variables. This makes a single copy of the strings and also protects against any potential typos in future uses.

KeyFactory keyFactory = datastore.newKeyFactory().setKind("Task");

// Print the value so you can see it in the server logs.
System.out.println(clientName + ": " + clientPassword);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what the requirements are for this but we may want to reconsider the safety implications of printing the password.


public Task(long id, String names, String lastNames, String username,
long timestamp) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Style nit: You can get rid of this empty extra line.

}

public String getUsername() {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Style nit: You can get rid of this empty extra line.


// check if the username exists in the database
boolean existUsername = true;
for (int i = 0; i < tasks.size(); i++){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that you can make this more efficient by storing a set or map of usernames and then checking if the username exists there. It would be O(1) runtime instead of O(n) (please reach out if you have further questions about this!)

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