-
Notifications
You must be signed in to change notification settings - Fork 54
Principle: Write only one algorithm to accomplish a task. #562
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -24,6 +24,23 @@ Required IDs: using-http | |||||||
|
||||||||
Link Defaults: html (dfn) queue a task/in parallel/reflect | ||||||||
</pre> | ||||||||
<pre class="biblio"> | ||||||||
{ | ||||||||
"draft-ietf-oauth-sd-jwt-vc": { | ||||||||
"href": "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-sd-jwt-vc", | ||||||||
"title": "SD-JWT-based Verifiable Credentials (SD-JWT VC)", | ||||||||
"status": "Internet-Draft", | ||||||||
"publisher": "IETF" | ||||||||
}, | ||||||||
"vc-data-model-1.1": { | ||||||||
"href": "https://www.w3.org/TR/vc-data-model-1.1/", | ||||||||
"title": "Verifiable Credentials Data Model v1.1", | ||||||||
"status": "REC", | ||||||||
"publisher": "W3C", | ||||||||
"deliveredBy": ["https://www.w3.org/groups/wg/vc"] | ||||||||
} | ||||||||
} | ||||||||
</pre> | ||||||||
<pre class="link-defaults"> | ||||||||
spec:css-cascade-5; type:dfn; text:inherit | ||||||||
spec:css2; type: property; text: line-height | ||||||||
|
@@ -3488,6 +3505,52 @@ While the best path forward may be to choose not to specify the feature, | |||||||
there is the risk that some implementations | ||||||||
may ship the feature as a nonstandard API. | ||||||||
|
||||||||
<h3 id="multiple-algorithms">Write only one algorithm to accomplish a task</h3> | ||||||||
|
||||||||
When specifying how to accomplish a task, write a single algorithm to do it, | ||||||||
instead of letting implementers pick between multiple algorithms. | ||||||||
It is very difficult to ensure that | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
two different algorithms produce the same results in all cases, | ||||||||
and doing so is rarely worth the cost. | ||||||||
|
||||||||
Multiple algorithms seem particularly tempting when defining | ||||||||
|
||||||||
how to parse file formats, | ||||||||
but they are an equally bad idea in that context. | ||||||||
|
||||||||
<div class="example" id="html-polyglot"> | ||||||||
|
||||||||
[[html-polyglot inline]] was an attempt to define a common subset of both XHTML and HTML | ||||||||
that could be parsed into equivalent DOM trees | ||||||||
using either the [[HTML#the-xhtml-syntax|XHTML parsing]] | ||||||||
or [[HTML#syntax|HTML parsing]] algorithm. | ||||||||
Authors who tried to use this syntax tended to produce documents | ||||||||
that actually only worked with one of the two parsers. | ||||||||
|
that actually only worked with one of the two parsers. | |
that only worked with one of the two parsers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manu is right that these are completely different (and that they likely represent standardization failure, though the question of where the failure occurred might be contested). In a sense, it is OK that they are completely different (that they are in competition is potentially bad if they address the same use cases, but there is no risk that one might be mistaken for the other).
I think that it would serve this example better to focus only on the CID case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement is incorrect. The VCDMv2 only has a single media type: application/vc
.
Likewise, SD-JWT-VC only has one: application/dc+sd-jwt
. However, SD-JWT is not JSON parse-able base format.
Both specifications have parsing algorithms unique to their media types--and specific to their tasks.
It remains unclear how these examples are "polyglot".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn’t the real difference here that the suffix parsing produces an intermediate result?
i suspect that this is insufficient still, because it doesn’t really get at why suffix parsers exist. That is still somewhat contested, but my view is that intermediate results are rarely able to be processed meaningfully, so they are limited to use in diagnostic tools and the like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "goal" instead of "task"? This immediately made me think of the event loop.