Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boundaries - Using Third-Party Code #32

Open
jnguyen095 opened this issue Jul 27, 2017 · 0 comments
Open

Boundaries - Using Third-Party Code #32

jnguyen095 opened this issue Jul 27, 2017 · 0 comments

Comments

@jnguyen095
Copy link
Owner

  • 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 );```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant