Best practices for nyan API
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.4k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
The API (and nyan itself) sometimes allows us to do the same thing in different ways. For common cases, we should figure out what the "best" approach is (i.e. the most resilient/readable/clean/understandable approach) and document them. We also need them for #970 when we write the converter. Best practices could be established for simple things such as object/member names or involve larger concepts.
Simple example
Removing 5 HP to a unit via a patch can be done in two ways:
- Subtract
5from HP value:hp -= 5 - Add
-5to HP value:hp += -5
Here, the former version is probably more intuitive.
API example
Adding 20% HP to all units of a civilization can be done in multiple ways:
- Patch all HP values and HP upgrades by multiplying with
1.2 - Patch a
Attribute(MultiplierModifier)withmultiplier = 1.2into every unit - Patch a
Attribute(MultiplierModifier)withmultiplier = 1.2into the civilization
Solution 1 works, but is probably too complex and does not work well with other mods. Solution 2 works with other stat modifying mods. Solution 3 is the easiest as we only need to add a modifier to the civilization. However, in comparison to solution 2 the modifier will not carry over when the unit is converted and there is no control over it during state changes (construction, damage, etc.).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests. Start by reviewing the nyan API patterns and the examples described here, then identify the common cases that need documented guidance. Done means a decided set of readable, resilient best practices covering naming and larger API choices, with guidance relevant to converter work in #970.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100