Add documentation on preferring binary enums over booleans#59
Add documentation on preferring binary enums over booleans#59dragon-ai-agent merged 1 commit intomainfrom
Conversation
Add documentation explaining why binary enums are often preferred over boolean types, drawing from the tidyverse design principles. Covers extensibility, clarity, self-documenting code, and the "name the scale" pattern. Includes LinkML-specific examples. Reference: https://design.tidyverse.org/boolean-strategies.html
|
Claude finished @cmungall's task —— View job Code Review AnalysisI've completed a comprehensive review of this documentation PR. Overall, this is an excellent addition to the LinkML valuesets project that provides clear guidance on schema design principles. Todo List:
✅ StrengthsHigh-Quality Technical Content:
LinkML Integration:
Practical Value:
🔍 Areas for EnhancementMinor Technical Issues:
Documentation Structure:
🚀 Suggestions
🔒 Security & Performance
📋 Index.md ChangesThe changes to
🎯 Overall AssessmentThis PR significantly enhances the project's documentation quality. The binary enums guidance addresses a common schema design challenge with clear, practical advice. The document is well-researched, technically sound, and aligns with established software design principles. Recommendation: ✅ Approve with minor suggestions The minor issues noted above don't detract from the overall value of this contribution. This document will serve as an excellent reference for LinkML schema designers. |
There was a problem hiding this comment.
Pull request overview
Adds a new “Explanations” document to the LinkML schema docs advocating for two-element enums over booleans, and links it from the docs home page to improve discoverability.
Changes:
- Added a new explanation doc: “Prefer Binary Enums Over Booleans”.
- Updated
docs/index.mdto include a new “Explanations” section linking to the new doc.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/index.md | Adds an “Explanations” section and links to the new guide. |
| docs/explanations/binary-enums-vs-booleans.md | New documentation page explaining the rationale and providing LinkML-oriented examples. |
| ### Binary Enum Pattern | ||
|
|
||
| ```yaml | ||
| enums: | ||
| SortDirection: | ||
| permissible_values: | ||
| ASCENDING: | ||
| description: Sort from lowest to highest | ||
| meaning: SIO:001395 # ascending order | ||
| DESCENDING: | ||
| description: Sort from highest to lowest | ||
| meaning: SIO:001396 # descending order | ||
|
|
||
| StrandOrientation: | ||
| permissible_values: | ||
| FORWARD: | ||
| description: Forward/plus strand | ||
| meaning: SO:0000853 # forward_strand | ||
| REVERSE: | ||
| description: Reverse/minus strand | ||
| meaning: SO:0000854 # reverse_strand | ||
|
|
||
| PresenceStatus: | ||
| permissible_values: | ||
| PRESENT: | ||
| description: The entity is present | ||
| ABSENT: | ||
| description: The entity is absent | ||
| NOT_DETERMINED: | ||
| description: Presence could not be determined | ||
| ``` |
There was a problem hiding this comment.
This section is titled “Binary Enum Pattern”, but the PresenceStatus example includes three permissible values (adds NOT_DETERMINED). That’s a good illustration of extensibility, but it’s no longer a binary enum and may confuse readers. Consider moving PresenceStatus into its own “Extending a binary enum” example or renaming the section to reflect that it includes non-binary cases.
| sample: | ||
| is_control: false | ||
|
|
||
| # Self-explanatory | ||
| sample: |
There was a problem hiding this comment.
The YAML snippet under “Self-Documenting Code” contains two sample: top-level keys in the same YAML document, which makes the example invalid (the second key overwrites the first). Consider splitting this into two separate code blocks or using distinct keys (e.g., sample1/sample2) so readers can copy/paste valid YAML.
| sample: | |
| is_control: false | |
| # Self-explanatory | |
| sample: | |
| sample1: | |
| is_control: false | |
| # Self-explanatory | |
| sample2: |
Summary
This PR adds a comprehensive explanation document to the LinkML schema documentation that advocates for using two-element enumerations instead of boolean types in schema design.
Key Changes
New document:
docs/explanations/binary-enums-vs-booleans.md- A detailed guide explaining why binary enums are preferable to booleans, including:Updated navigation:
docs/index.md- Added a new "Explanations" section with a link to the binary enums guideNotable Details
The document draws from established design principles (tidyverse's Tidy Design Principles) and provides concrete examples relevant to LinkML users, including ontology mapping with
meaningannotations and practical use cases like sort direction and strand orientation.https://claude.ai/code/session_012NRY1cEkUdQyExXFvJZUmv