Skip to content

Comments

docs: Add Kotlin language standards (#33)#34

Open
jjhafer wants to merge 1 commit intosilvermine:masterfrom
jjhafer:33_add_kotlin_standards
Open

docs: Add Kotlin language standards (#33)#34
jjhafer wants to merge 1 commit intosilvermine:masterfrom
jjhafer:33_add_kotlin_standards

Conversation

@jjhafer
Copy link

@jjhafer jjhafer commented Jul 26, 2025

Document our Kotlin language standards for upcoming projects.

  • Add kotlin.md and reference it in coding-standards.md.

Document our Kotlin language standards for upcoming
projects.

* Add `kotlin.md` and reference it in `coding-standards.md`.
@jjhafer jjhafer force-pushed the 33_add_kotlin_standards branch from d82d00c to ccbad26 Compare July 26, 2025 17:15
@jjhafer
Copy link
Author

jjhafer commented Jul 28, 2025

@yokuze @velocitysystems Could you review this MR? Similar to the Swift standards, @velocitysystems can you consult with App Dev and come back with any suggestions on the Kotlin standards? And @yokuze, please verify that this matches what you expect in the repo?

@yokuze yokuze requested review from velocitysystems and yokuze July 29, 2025 22:11
@yokuze yokuze self-assigned this Jul 29, 2025
Copy link
Contributor

@yokuze yokuze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you get any PR comments to address, then you could add trailing . to the bullet points in the first couple sections to match the last few sections, or vice-versa, but that's super minor and not worth your time unless you're already pushing.

Structure and content LGTM, but leaving the full content review up to @velocitysystems

Copy link

@mnkyby78 mnkyby78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry - this is my first review directly in Github. See my comments on the file itself.

// Good:
/**
* Returns the user with the given ID.
* @param userId The ID of the user to return.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow for the omission of self explanatory comments? I think userId would be good candidate for a parameter that does not need a comment explaining what it is.

* No blank line before closing brace
* One space after colon in type declarations
* No space before colon in type declarations
* One newline at the end of the file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a standard, perhaps under Whitespace, for closing parenthesis on functions that wrap lines? Like someFunctionWithAVeryLongName in the Line Length section - we want the closing parenthesis by itself on a new line, aligned left with the starting point

// ...
}
```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment that we prefer simplicity, readability, and debuggability over clever solutions? We want future devs (or ourselves) to be able to quickly understand what's happening.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like this, and the Write comments to explain *why* code is written a certain way, not *what* the code does. above would be even better if they lived in the https://github.com/silvermine/silvermine-info/blob/master/coding-standards.md file since they're good principles that apply to all languages

@@ -0,0 +1,174 @@
# Silvermine Coding Standards Specific to Kotlin

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @jjhafer. Just a few thoughts when comparing with the official Kotlin coding conventions:

  • Do we need to clarify bracing style e.g. always use braces for if/else, even for single-line blocks)?
  • Do we need to include a comment about using explicit visibility modifiers? e.g. private, internal.
  • Should we recommend using properties val / var over backing fields where possible?
  • Should we encourage the use of Kotlin collections e.g. listOf, mutableListOf rather than Java collections? What about best-practice for mutability e.g. read-only by default?
  • Should we add a section for imports e.g. avoidance of wildcard imports and organizing imports per Kotlin conventions?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing against our previous internal standards, just a few additional comments:

  • Do we wish to include a copyright header in each file?
  • Do we wish to recommend use of early return style vs. nested conditionals? (May be less Kotlin-specific)
  • Should enums/enum values be documented?

* No blank line before closing brace
* One space after colon in type declarations
* No space before colon in type declarations
* One newline at the end of the file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Add newline after closing curly brackets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants