gameontext / sample-room-java

Walkthrough for creating a room in java for Game On!
https://gameontext.org
Apache License 2.0
20 stars 105 forks source link

Map client #26

Closed pavittr closed 8 years ago

pavittr commented 8 years ago

Fixes #14

This change is Reviewable

ebullient commented 8 years ago

Reviewed 12 of 13 files at r1. Review status: 12 of 13 files reviewed at latest revision, 13 unresolved discussions.


gojava-application/src/main/java/application/Application.java, line 164 at r1 (raw file):

Quoted 5 lines of code… > ``` > RoomInfo roomInfo = getRoomInfo(); > if (roomInfo != null) { > response.add(NAME, roomInfo.getName()); > String description = roomInfo.getDescription(); > response.add(DESCRIPTION, (description == null) ? "A badly described room" : description); > ``` > >

Make RoomInfo a member variable, to make it easier for the room description to be reused/updated/forwarded between addNewPlayer and processCommand (below)

getRoomInfo should make sure that it always returns an object..


gojava-application/src/main/java/application/Application.java, line 201 at r1 (raw file):

              response.add(NAME, roomInfo.getName());
              String description = roomInfo.getDescription();
              response.add(DESCRIPTION, (description == null) ? "A badly described room" : description);

This is duplicate code for above. Simplify with a reusable RoomInfo object.

Might add as a comment around that RoomInfo object that a room could consider changing its description at runtime over time, or per user, or across instances, or...


[gojava-application/src/main/java/application/Application.java, line 216 at r1](https://reviewable.io:443/reviews/gameontext/gameon-room-java/26#-KTtBYvY57UD18uOnwa:-KTtBYvtrtwOLE-Mrpd:b-74biko) (raw file):

            }

            if ( exitDirection == null) {

You do still need to make sure that all exits are defined. They should be, but accidents happen.


gojava-application/src/main/java/map/client/Log.java, line 27 at r1 (raw file):

 */
public class Log {
    private final static Logger log = Logger.getLogger("net.wasdev.gameon.mediator");

Bad package here...


gojava-application/src/main/java/map/client/Log.java, line 57 at r1 (raw file):

     * @return Original Level or INFO level, whichever is greater
     */
    private static Level useLevel(Level level) {

We might use a variable here to determine whether or not this takes effect. Should be possible to not do this level promotion in some environments.


_gojava-application/src/main/java/map/client/MapClient.java, line 51 at r1 (raw file):_

public class MapClient {

  private static final String mapLocation = "https://game-on.org/map/v1/sites";

Should still allow this to be injected (and cope if it isn't). We have the possibility on the horizon for additional domains for test/staging... would be nice for the example to handle that.


gojava-application/src/main/java/map/client/MapResponseReader.java, line 31 at r1 (raw file):

@Provider
@Consumes(MediaType.APPLICATION_JSON)
public class MapResponseReader implements MessageBodyReader<Site> {

We need this because we aren't using Jackson?


gojava-application/src/main/java/map/client/MapResponseReader.java, line 58 at r1 (raw file):

          site.setType(sanitiseNull(returnedJson.getJsonString("type")));
          site.setId(sanitiseNull(returnedJson.getJsonString("_id")));

Why do we need to sanitize null? (because we aren't using Jackson that automatically ignores null attributes?) (especially given that we are using Jackson w/ annotations below?)


gojava-application/src/main/java/map/client/model/Doors.java, line 20 at r1 (raw file):

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)

Also need @JsonInclude(Include.NON_EMPTY) .. though we won't be marshalling these back out in the usual course of things


gojava-application/src/main/java/map/client/model/Exit.java, line 17 at r1 (raw file):

 *******************************************************************************/
package map.client.model;

Comments. Jackson annotations for avoiding empty values and ignoring unknown attributes


_gojava-application/src/main/java/map/client/model/Exits.java, line 22 at r1 (raw file):_

import javax.json.JsonObjectBuilder;

public class Exits {

JAckson annotations for ignoring nulls and unknown attributes


_gojava-application/src/main/java/map/client/model/RoomInfo.java, line 18 at r1 (raw file):_

package map.client.model;

public class RoomInfo {

Jackson annotations for ignoring unknown and empty attributes Should include assigning dummy strings for missing descriptive values


gojava-application/src/main/java/map/client/model/Site.java, line 17 at r1 (raw file):

 *******************************************************************************/
package map.client.model;

Jackson annotations for ignoring unknown/empty attributes.


Comments from Reviewable

ebullient commented 8 years ago

Reviewed 1 of 13 files at r1. Review status: all files reviewed at latest revision, 13 unresolved discussions.


Comments from Reviewable

pavittr commented 8 years ago

Review status: 5 of 20 files reviewed at latest revision, 13 unresolved discussions.


gojava-application/src/main/java/application/Application.java, line 164 at r1 (raw file):

Previously, ebullient (Erin Schnabel) wrote… > > ``` > > RoomInfo roomInfo = getRoomInfo(); > > if (roomInfo != null) { > > response.add(NAME, roomInfo.getName()); > > String description = roomInfo.getDescription(); > > response.add(DESCRIPTION, (description == null) ? "A badly described room" : description); > > ``` > > Make RoomInfo a member variable, to make it easier for the room description to be reused/updated/forwarded between addNewPlayer and processCommand (below) > > getRoomInfo should make sure that it always returns an object.. >

Done.


gojava-application/src/main/java/application/Application.java, line 201 at r1 (raw file):

Previously, ebullient (Erin Schnabel) wrote… > This is duplicate code for above. Simplify with a reusable RoomInfo object. > > Might add as a comment around that RoomInfo object that a room could consider changing its description at runtime over time, or per user, or across instances, or... >

Done.


[gojava-application/src/main/java/application/Application.java, line 216 at r1](https://reviewable.io:443/reviews/gameontext/gameon-room-java/26#-KTtBYvY57UD18uOnwa:-KTxtp-As3bDMwyvE-8:b-896fix) (raw file):

Previously, ebullient (Erin Schnabel) wrote… > You do still need to make sure that all exits are defined. They _should_ be, but accidents happen. >

Done.


gojava-application/src/main/java/map/client/Log.java, line 27 at r1 (raw file):

Previously, ebullient (Erin Schnabel) wrote… > Bad package here... >

Done.


gojava-application/src/main/java/map/client/Log.java, line 57 at r1 (raw file):

Previously, ebullient (Erin Schnabel) wrote… > We might use a variable here to determine whether or not this takes effect. Should be possible to _not_ do this level promotion in some environments. >

Done.


_gojava-application/src/main/java/map/client/MapClient.java, line 51 at r1 (raw file):_

Previously, ebullient (Erin Schnabel) wrote… > Should still allow this to be injected (and cope if it isn't). We have the possibility on the horizon for additional domains for test/staging... would be nice for the example to handle that. >

Done.


gojava-application/src/main/java/map/client/MapResponseReader.java, line 31 at r1 (raw file):

Previously, ebullient (Erin Schnabel) wrote… > We need this because we aren't using Jackson? >

Yes, basically. I was planning on having an example of using JSON-P


gojava-application/src/main/java/map/client/MapResponseReader.java, line 58 at r1 (raw file):

Previously, ebullient (Erin Schnabel) wrote… > Why do we need to sanitize null? (because we aren't using Jackson that automatically ignores null attributes?) (especially given that we are using Jackson w/ annotations below?) >

Yeah that is part of it.


_gojava-application/src/main/java/map/client/model/Doors.java, line 20 at r1 (raw file):_

Previously, ebullient (Erin Schnabel) wrote… > Also need @JsonInclude(Include.NON_EMPTY) .. though we won't be marshalling these back out in the usual course of things >

Removed so we can focus on JSON-P


_gojava-application/src/main/java/map/client/model/RoomInfo.java, line 18 at r1 (raw file):_

Previously, ebullient (Erin Schnabel) wrote… > Jackson annotations for ignoring unknown and empty attributes > Should include assigning dummy strings for missing descriptive values >

So not doing this as a result of focusing on JSON-P. For the null attributes, I don;t want to force non-null values at this stage as it might


gojava-application/src/main/java/map/client/model/Site.java, line 17 at r1 (raw file):

Previously, ebullient (Erin Schnabel) wrote… > Jackson annotations for ignoring unknown/empty attributes. >

Handled


Comments from Reviewable

pavittr commented 8 years ago

Review status: 5 of 20 files reviewed at latest revision, 13 unresolved discussions.


gojava-application/src/main/java/map/client/model/Exit.java, line 17 at r1 (raw file):

Previously, ebullient (Erin Schnabel) wrote… > Comments. > Jackson annotations for avoiding empty values and ignoring unknown attributes >

Handled


_gojava-application/src/main/java/map/client/model/Exits.java, line 22 at r1 (raw file):_

Previously, ebullient (Erin Schnabel) wrote… > JAckson annotations for ignoring nulls and unknown attributes >

Handled


Comments from Reviewable

ebullient commented 8 years ago

Reviewed 17 of 17 files at r2. Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable