Skip to content
This repository has been archived by the owner on Sep 14, 2019. It is now read-only.

The get*() methods that are used to access SmartDashboard can fail silently #21

Open
brettle opened this issue Jan 16, 2018 · 4 comments
Assignees

Comments

@brettle
Copy link
Member

brettle commented Jan 16, 2018

I'm referring to methods like this one:

public int getButton(String key, int def) {
if (!SmartDashboard.containsKey(key)) {
SmartDashboard.putNumber(key, def);
}
return (int) SmartDashboard.getNumber(key, def);
}

Consider what happens if there is already an entry with the requested key but it is of a different type.

@brettle
Copy link
Member Author

brettle commented Jan 16, 2018

@doawelul
Copy link
Contributor

It would just return the default. However, this should never be the case since the convention I already set (and tbh will most likely change, this is one great reason why it shouldn't change) is greatly specific ("such as 'Button/Shift Drive' or 'Port/LeftTalonSRXDrive' [the booleans are a separate matter that will be dealt with (hopefully) tomorrow to the existing standard]) therefore imo at least there is no worry about overlap of keys. (Sorry for so many parentheses so here's some more)

@brettle
Copy link
Member Author

brettle commented Jan 17, 2018

"this should never be the case" + "convention" + Murphy's Law = "this is bound to happen at some point"

My concern here is with the fact that there is no indication that this unexpected condition has occurred. Simply logging the error is sufficient.

@doawelul
Copy link
Contributor

doawelul commented Feb 10, 2018

Added printing to Standard Error in last commit (currently in a pull request)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants