Skip to content

Boundaries - Using Third-Party Code #32

Description

@jnguyen095
  • If our application needs a Map of Sensors, you might find the sensors set up like this:
    java Map sensors = new HashMap();
  • Then, when some other part of the code needs to access the sensor, you see this code:
    java Sensor s = (Sensor)sensors.get(sensorId );
  • This works, but it’s not clean code. Also, this code does not tell its story as well as it
    could.
  • The readability of this code can be greatly improved by using generics, as shown
    below:
Map<Sensor> sensors = new HashMap<Sensor>();
...
Sensor s = sensors.get(sensorId );```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions