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
Different Description Of The Command Being Decorated In Documentation And The Hover-Over JavaDocs #6539
Comments
The case you're bringing up is indeed a mistake that can be easily made with the amount of parentheses involved. Yet I'm not sure what practical steps can be taken, especially on the library side. Similar pitfalls happen with mathematical order of operations, and API docs have nothing to do with it: it's a question of code readability. The most helpful solution I've found is to indent blocks commands on the same level; this becomes easier with prefix syntax (= factories) but is possible also in infix/postfix syntax (= decorators). |
Either I misunderstand what you mean or this is not correct - either are the problem I suggest fixing at least with more "inline" documentation (more words, examples) because I, too, can't think of a better syntax to mitigate the problem other than using In my example BUT that is not the command that is modified. The command that receives the Yes, the correct placement of that last |
Note what's going on here: run(()->System.out.println("command 1e " + Timer.getFPGATimestamp())).withTimeout(2.)
.andThen(run(()->System.out.println("command 2e " + Timer.getFPGATimestamp()))).withTimeout(2.)
.andThen(run(()->System.out.println("command 3e " + Timer.getFPGATimestamp()))).withTimeout(1.)
.schedule(); The expression in the lhs/receiver position of that third To mirror the math metaphor, the difference is similar to the difference between the following two expressions:
Or in this case with commands: // Sequence of a and b, with a timeout on the sequence.
a.andThen(b).withTimeout(s)
// Same as before, extract temp to a variable
tmp = a.andThen(b)
tmp.withTimeout(s)
// ---------
// b has a timeout and is added to a sequence after a
a.andThen(b.withTimeout(s))
// Same as previous, extract temp to variable
tmp = b.withTimeout(s)
a.andThen(tmp) I hope this is clearer. |
Yes, I like your example; this is exactly what I suggest is needed in the methods' Javadocs. Here's a proposed slight change to the existing wording of the
|
I'm still not seeing how this is an API docs issue - it's a readability and order-of-operations issue. Adding the full content with an example etc to each decorator's docs would be too verbose, but can be added to an frc-docs page. We can add a "take note of function call receiver association, see {docs link}" (but phrased better) to the API docs along with the double composition notice? |
Example code in Javadocs is exceedingly rare but it has happened; maybe not this time, though. Anything that can be done to better document and train users on a couple of idiosyncrasies of compositions is of benefit.
account for almost all the errors of command-based usage (once the correct command is selected for the problem). |
In the documentation of the use of the many command decorators it is not as descriptive as we need for what is the command that is being decorated. I think most or all of the decorators could better describe the command but an especially glaring problem arises when using
.andThen()
and.withTimeout()
.The results of these illustrative snippets are for the most part disconcerting and are significant coding errors made by my team and myself. Especially how can a
.withTimeout(1.)
on the line forcommand 3e
effectcommand 1e
andcommand 2e
? It's hard to find the error in the code, it takes too much effort to understand why this happens this way, the answer isn't readily remembered and the Javadocs are not helpful when stuck on this problem.[A circumvention of the problem is to use
sequence()
but I like.andThen()
for its ability to delimit commands better than the,
in thesequence( , , ,)
.]Stronger clarification of what is the command versus a string of decorators is much needed.
The text was updated successfully, but these errors were encountered: