Article 50KPG Simple Class

Simple Class

by
Jane Bailey
from The Daily WTF on (#50KPG)

480px-JSON_vector_logo.svg.png

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")@Exposeprivate String $schema;@SerializedName("title")@Exposeprivate String title;@SerializedName("type")@Exposeprivate String type;@SerializedName("properties")@Exposeprivate Properties properties; // ... getters & setters}public class Properties {@SerializedName("enabled")@Exposeprivate Enabled enabled;@SerializedName("keyId")@Exposeprivate KeyId keyId; // ... getters & setters}public class KeyId {@SerializedName("type")@Exposeprivate String type;@SerializedName("description")@Exposeprivate String description; // ... getters & setters}public class Enabled {@SerializedName("type")@Exposeprivate String type;@SerializedName("description")@Exposeprivate 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.

proget-icon.png [Advertisement] ProGet can centralize your organization's software applications and components to provide uniform access to developers and servers. Check it out! TheDailyWtf?d=yIl2AUoC8zAKVxQ33HJWDM
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments