-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add enhancements to existing prototype features in the go feature. #22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to think about creating a new ScavengerHuntManager javascript class that is responsible the business logic of managing the flow of the scavenger hunt.
This would be convenient because it would allow you to better encapsulate functions and variables, which right now are global.
For example, something like this:
class ScavengerHuntManager {
constructor() {}
fetchData() {
this.scavengerHuntData = // result of the fetch call
this.currentIndex = // whatever
}
start() {}
proceed() {}
exit() {}
etc.
}
Don't feel like you need to do this with this PR, but I would encourage you to think about how you can use object oriented programming here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked at all of it, but these are the comments I have so far
@@ -22,10 +22,12 @@ | |||
// For saved scavenger hunts: represents which destination the user is currently looking for. | |||
private int index; | |||
private String city; | |||
private String guess; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of storing a guess as part of the ScavengerHunt
data? Maybe there's an upcoming change that you're planning that would help me understand better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this in primarily for the convenience of being able to easily convert all of the data sent to /go-data into one JSON object -- it's not really relevant to the ScavengerHunt data itself.
} catch (Exception e) { | ||
} | ||
|
||
nameGuess = request.getParameter(NAME_PARAMETER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this design is that the client is expected to send only an index XOR a guess. Because those are two different pieces of functionality, they should be more clearly separated. I think separating them by having different URL paths for each would be the most simple and clear way of doing this*. I'm not sure how to configure a servlet to handle multiple different URL paths, but I imagine there's a way, otherwise you could write an additional servlet class for the different path. I can help you look for a way to do multiple paths in the same class later on if you'd like.
- Other ideas include having an additional parameter that specifies which set of functionality the client wants from the server for this request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense -- I think it'd be clearer if I split GoDataServlet into two separate servlets to handle getting the scavenger hunt data and getting the user's answer separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Start:
After clicking the start button:
After inputting the correct destination name:
After completing the hunt: