Closed ebullient closed 7 years ago
Reviewed 11 of 26 files at r1. Review status: 11 of 24 files reviewed at latest revision, 12 unresolved discussions.
gojava-application/src/main/java/org/gameontext/sample/Log.java, line 63 at r1 (raw file):
// much easier to read if the default behaviour is to have this level // promotion switched on if ( level.intValue() < Level.INFO.intValue() && !NO_LOG_LEVEL_PROMOTION) {
Wondering here about stuff javac would likely optimise away, but I'd normally put the fixed constant part of the && statement first, and have the level int comparison after, as conceptually, the comparison will only need to be performed if the bool expression is false.. I'd hope a good compiler could imply that from this statement, but even so.. easy change..
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 19 at r1 (raw file):
* This is how our room is described. * a) Use post-construct to go fill some of this in by asking the map * b) Assign this dynamically on the fly as the room is used.
what are a) b) here.. ? order of operation? mutually exclusive usage patterns? #confusingcomment I can't find reference to a) b) later in this file.
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 94 at r1 (raw file):
} /**
There's no synchronization protection over get/add/remove, and get iterates the entryset, which is modified by add/remove .. caution needed here if these are driven in response to external events on concurrent threads.
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 128 at r1 (raw file):
/** * Room inventory objects are optional. Build/cache/return a JsonArray listing * items in the room for use in location messages.
same issue re commands / concurrency
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 93 at r1 (raw file):
// Who doesn't love switch on strings in Java 8? switch(message.getTarget()) {
This feels nicer than before.. but the length of this switch statement is unfortunate.. admittedly a good 50% of that is the json commenting..
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 179 at r1 (raw file):
String contentToLower = content.toLowerCase(Locale.ENGLISH).trim(); String firstWord;
String parts[] = contentToLower.split(" ",2); //split limit.. shiny ;p String firstWord = parts[0]; String remainder = parts.length > 1 ? parts[1] : null; //array will only have 1 element if string had no spaces..
(also look at java.util.Scanner it can make token processing string input a lot simpler.. although it doesn't easily handle the 'remainder' pattern here, you could pass the Scanner instance around allowing getDirection etc to process the remaining string as required.. {can sort of emulate remainder if you add \n to the string then use scanner nextLine to glob the rest of the line.. ymmv} .. )
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 249 at r1 (raw file):
}
the direction stuff here feels.. awkward.. like direction should be some sort of construct that handles all this mapping between text and short & long for you, so it's not duplicated between the two methods (note that getDirection will return null for up / down, while long direction supports those concepts.. if that's intentional, it could do with a comment explaining why)
gojava-application/src/main/java/org/gameontext/sample/map/client/MapResponseReader.java, line 58 at r1 (raw file):
try { rdr = Json.createReader(entityStream); JsonStructure json = rdr.read();
JsonObject returnedJson = rdr.readObject(); ??
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 42 at r1 (raw file):
private static final String PREFIX = "room-" + RoomImplementation.ROOM_ID + "-"; /** Incrementing message id for bookmark */
I wonder if we shouldn't init this long with say, System.currentMillis() / 100 or something.. to ensure each run of the same room generates differing bookmark ids in the ui
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 71 at r1 (raw file):
/** * Ack message: this supports version 1 & 2 * {@code ack,{\"version\":[1]}}
hmm.. should this comment say 1|2 ?
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageDecoder.java, line 45 at r1 (raw file):
@Override public boolean willDecode(String s) { return true;
meh.. suspect this should only return true if new Message(s) won't through a DecodeException ? not sure though.
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageEncoder.java, line 40 at r1 (raw file):
@Override public String encode(Message msg) throws EncodeException { return msg.toString();
wondering if this shouldn't call a more appropriately named method to encode msg to json, I know toString is javadoc'd to say it returns json, but I kinda prefer having toString, and formatted outputters be distinct, to allow toString to be embellished for debug/log without affecting operation
Comments from Reviewable
Reviewed 12 of 26 files at r1. Review status: 21 of 24 files reviewed at latest revision, 12 unresolved discussions.
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 255 at r1 (raw file):
} switch(lowerDirection) {
Below you include up and down, here you don't. Not sure to me why?
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/map/client/MapClient.java, line 78 at r1 (raw file):
if (mapLocation == null) { MapClientLog.log(Level.FINER, this, "No MAP_URL environment variable provided. Will use default."); mapLocation = "https://game-on.org/map/v1/sites";
Should this be a constant?
Comments from Reviewable
Review status: 21 of 24 files reviewed at latest revision, 14 unresolved discussions.
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 19 at r1 (raw file):
Changes would be made in RoomImplementation (where this is a member variable), not here.
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 94 at r1 (raw file):
Wasn't sure I should have to deal with all of that up front, or leave some as exercises for the reader. But I suppose I should just go do that...
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 179 at r1 (raw file):
Not sure it matters that much? Splitting into an array is not necessarily more readable.. We'll see what Ilan says. :-P
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 249 at r1 (raw file):
Yes.. first one is a filter (is it something I know about or not). Second one makes it pretty for display. I'll clarify.
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 255 at r1 (raw file):
I can remove Up/Down here (cut/paste from other code elsewhere)
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 71 at r1 (raw file):
or 1 || 2
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 139 at r1 (raw file):
// } JsonObjectBuilder oayload = Json.createObjectBuilder(); oayload.add(TYPE, EVENT);
should this be 'payload' ?
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 396 at r1 (raw file):
* @see MessageDecoder#decode(String) */ public Message(String s) throws DecodeException {
maybe worth considering looking at the format of the message again so it becomes trivial and doesn't require decoding. Make the whole thing JSON, instead of this hybrid CSV, JSON?
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 494 at r1 (raw file):
} @Override
This is a bit of a head scratcher.
Comments from Reviewable
Review status: 21 of 24 files reviewed at latest revision, 17 unresolved discussions.
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 93 at r1 (raw file):
Y.. if you removed all the commenting, it would be teeny. I don't feel compelled to change it.. ?
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 42 at r1 (raw file):
y.. I wondered about that. I was half going for something readable. Having something unique to the room in the bookmark is a nice visual indicator in the client console..
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 71 at r1 (raw file):
No. it supports both versions.
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 139 at r1 (raw file):
LOL. yes.
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 396 at r1 (raw file):
harder to stop parsing midstream, isn't it? I know this is the single biggest concern.. but there isn't a good way (otherwise) for me to direct traffic in the middle without parsing more of the JSON message than I want to.
With message queues you have a topic. With websockets, we don't. The content-before the JSON payload is the rough equivalent of a topic.
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 494 at r1 (raw file):
Generated.
Equals used to validate that created messages get parsed properly
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 94 at r1 (raw file):
If you want to leave as an exercise for the reader, just add a comment indicating that it may be needed under some condition and has been left consciously as an exercise for the reader?
Comments from Reviewable
Review status: 21 of 24 files reviewed at latest revision, 17 unresolved discussions.
gojava-application/src/main/java/org/gameontext/sample/map/client/MapResponseReader.java, line 58 at r1 (raw file):
Yes. let me simplify. ALso need tests for this one.
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 179 at r1 (raw file):
I find the current way easier to read and understand.
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 255 at r1 (raw file):
I like having more directions though, but Map can't handle that right?
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 494 at r1 (raw file):
I wondered if you wrote that out manually, and then wondered the mental space you would have been in, in the middle of that process.
Comments from Reviewable
Review status: 15 of 24 files reviewed at latest revision, 16 unresolved discussions.
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 19 at r1 (raw file):
Okie, so mebbe just clean up the comment to avoid the confusion.. it's just the use of a) b) that threw me, because it wasn't explained later, or here what the a & b were for.
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 94 at r1 (raw file):
A comment warning it's not threadsafe / or similar would at least give people the heads up.
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 93 at r1 (raw file):
I know.. I guess It'll have to live here.. the only choice left is to move the switch bodies into their own methods, but that carries a negative that I feel is roughly equiv to the over long switch anyways..
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 71 at r1 (raw file):
the code supports both.. the comment doesn't allow for the existence of 2
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 139 at r1 (raw file):
Nice catch! =)
Comments from Reviewable
Review status: 15 of 24 files reviewed at latest revision, 13 unresolved discussions, some commit checks failed.
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 32 at r2 (raw file):
private String description = "An undescribed room (or perhaps the data hasn't been fetched from the map)"; private Map<String, String> commands = new ConcurrentHashMap<>();
Yay ;p
Comments from Reviewable
Reviewed 1 of 26 files at r1, 5 of 7 files at r2. Review status: 20 of 24 files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.
Comments from Reviewable
Reviewed 1 of 7 files at r2. Review status: 21 of 24 files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 42 at r1 (raw file):
Well that wouldn't be incrementing then, though I guess its not incrementing now either. Unless the message id is incrementing and not the bookmark. What is the message id?
Comments from Reviewable
Review status: 21 of 24 files reviewed at latest revision, 9 unresolved discussions, some commit checks failed.
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 94 at r1 (raw file):
Meh. I made them threadsafe.
gojava-application/src/main/java/org/gameontext/sample/RoomImplementation.java, line 255 at r1 (raw file):
Map can't.. yet. This should hopefully make it clearer for us to explain how to get wormholes to work. There is a bit through the mediator I have to make sure works.. and then I think a room could manufacture its own wormholes.
gojava-application/src/main/java/org/gameontext/sample/map/client/MapClient.java, line 78 at r1 (raw file):
Done.
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 71 at r1 (raw file):
Comment changed
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 494 at r1 (raw file):
No way. Eclipse generates those.
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageDecoder.java, line 45 at r1 (raw file):
You'd have to pre-parse the message to be able to tell. I could pre-check that the string starts with "room"...
Comments from Reviewable
Review status: 21 of 24 files reviewed at latest revision, 7 unresolved discussions, some commit checks failed.
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 42 at r1 (raw file):
The last chunk is incrementing (the AtomicLong, just below)
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/Message.java, line 494 at r1 (raw file):
Aww.. You burst my bubble.
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageDecoder.java, line 45 at r1 (raw file):
depends on what "willDecode" means semantically. If it just means you can use the decode method and its implemented then its correct. How is this method intended to be used?
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageEncoder.java, line 40 at r1 (raw file):
I've been using Jackson lately, and this all has just been happening transparently. But maybe should be toJson
? but the I guess decode should be fromJson
?
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageEncoder.java, line 40 at r1 (raw file):
oops..I should have written instead of toString
. I cant seem to edit previous comments.
Comments from Reviewable
Review status: 17 of 24 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageDecoder.java, line 45 at r1 (raw file):
Given the usage, I'm inclined to agree with myself and answer true. Anything the decoder won't decode flowing on the websocket is an exception
Comments from Reviewable
Review status: 17 of 24 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageEncoder.java, line 40 at r1 (raw file):
I moved to encode. Because that's fine. the json as a string is perfectly readable. If/when it needs to be changed, it can be.
Comments from Reviewable
Review status: 17 of 24 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.
gojava-application/src/main/java/org/gameontext/sample/RoomDescription.java, line 19 at r1 (raw file):
Done.
Comments from Reviewable
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageDecoder.java, line 45 at r1 (raw file):
The JavaDoc is a bit self referential. 'Answer whether the given String can be decoded into an object of type T.' Is it meant to be called before attempting to decode, so you know there won't be an Exception; or is it to say you can attempt and won't get an 'Unsupported' Exception, but may get others.
Comments from Reviewable
Review status: 17 of 24 files reviewed at latest revision, 4 unresolved discussions.
gojava-application/src/main/java/org/gameontext/sample/protocol/MessageDecoder.java, line 45 at r1 (raw file):
So. in my experience, this is useful when you have many different types of things flying around on the socket, and there is some marker you can use to determine whether or not the string should be decoded by this decoder, instead of one of the others...
We aren't in that boat here.
Comments from Reviewable
Reviewed 15 of 26 files at r1, 4 of 7 files at r2, 7 of 7 files at r3. Review status: all files reviewed at latest revision, 4 unresolved discussions.
Comments from Reviewable
Comments from Reviewable
Signed-off-by: Erin Schnabel schnabel@us.ibm.com
This change is