JSON vector logo

Sometimes, you just know one of your coworkers isn't pulling his or her weight on the team. Sometimes it's the slacker co-worker, the one you always see browsing Facebook or getting coffee and never on pull requests or in architecture meetings. Sometimes it's the absent one, the one always seeming to be on sick leave or "working from home." And sometimes it's the guy who you wish would slack off just so you could stop reviewing his inane, poorly-executed code.

Danny was one of the latter types. He worked at a Fortune 50 company on a team of four; he had, in theory, 14 years of professional experience working for many huge companies as a software architect. Not only were his communication skills non-existent, his code was never tested and rarely worked. And yet somehow, he kept missing lower and lower bars of competence as our submitter watched in horror.

One of his tasks was to create a simple class that could hold the config for the new functionality. "That's simple," he said, before spending two whole days working on it. Our submitter came in the third day, grabbed some coffee, and began reviewing the PR Danny had submitted the evening prior. In order to hold a config like this:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Config",
  "type": "object",
  "properties": {
      "enabled": {
         "type": "boolean",
         "description":"xxx"
      },
      "keyId": {
        "type": "string",
        "description": "xxx"
      }
   }

He created a class like so:

public class Config {
	@SerializedName("$schema")
	@Expose
	private String $schema;
	@SerializedName("title")
	@Expose
	private String title;
	@SerializedName("type")
	@Expose
	private String type;
	@SerializedName("properties")
	@Expose
	private Properties properties;

        // ... getters & setters
}

public class Properties {
	@SerializedName("enabled")
	@Expose
	private Enabled enabled;
	@SerializedName("keyId")
	@Expose
	private KeyId keyId;

        // ... getters & setters
}

public class KeyId {
	@SerializedName("type")
	@Expose
	private String type;
	@SerializedName("description")
	@Expose
	private String description;

        // ... getters & setters
}

public class Enabled {
	@SerializedName("type")
	@Expose
	private String type;
	@SerializedName("description")
	@Expose
	private String description;

        // ... getters & setters
}

That's right: every single field in the JSON, including the schema definition, had a field in the class, with a getter and setter to match. It's as though he'd never seen JSON before in all his 14 years in the industry. Furthermore, even if this were the correct way to approach the topic, it should take about five minutes in IntelliJ to do it correctly, and yet Danny had spent two days doing ... what? Not testing, that's for sure.

He was fired the next week.

[Advertisement] ProGet can centralize your organization's software applications and components to provide uniform access to developers and servers. Check it out!