Coding Guidelines¶
These guidelines ensure consistency and quality across the plugin’s development. We follow standard practices for IntelliJ Platform SDK, Kotlin, and Python.
IntelliJ Platform SDK Practices¶
API Versioning: Always use the most recent, non-deprecated APIs. Check for
@Deprecatedannotations and follow suggestions in their Javadoc.Logging: Use
com.intellij.openapi.diagnostic.Loggerfor plugin logging instead ofprintlnor custom file logging for general diagnostic purposes.Services: Use the
@Serviceannotation for project-level or application-level services. Avoid manual singleton patterns.Process Execution: Use
com.intellij.execution.configurations.GeneralCommandLinefor launching external processes.File I/O: Prefer
java.nio.file.Pathand IntelliJ’sVfsUtil,FileUtil, orNioPathUtiloverjava.io.Filewhen interacting with the IDE’s virtual file system.Network: Use
com.intellij.util.io.HttpRequestsfor downloading files or making network requests.UI Components: Use IntelliJ-specific components like
JBLabel,JBTextField,JBCheckBox, andFormBuilderfor consistent UI.Progress: Long-running operations should be wrapped in
ProgressManager.getInstance().runProcessWithProgressSynchronouslyorrunModalto provide feedback.
Kotlin Styling Practices¶
Standard Conventions: Follow the official Kotlin Style Guide.
Immutability: Use
valby default. Only usevarwhen mutability is strictly required.Single-Expression Functions: Use expression bodies (
fun foo() = ...) for simple functions.Null Safety: Leverage Kotlin’s null safety effectively; avoid
!!where possible, prefer?:(elvis operator) or safe calls.Naming:
PascalCasefor classes, interfaces, and objects.camelCasefor functions, variables, and properties.UPPER_SNAKE_CASEfor constants.
String Templates: Prefer string templates (
"$foo") over concatenation.
Python Styling Practices¶
PEP 8: Follow PEP 8 standards for any Python scripts (like those injected into Blender).
Nesting: Keep nesting minimal (<= 4 levels of indentation).
Standard Library: Prefer using the Python standard library whenever possible.
Clean & Readable Code Practices¶
Single Responsibility Principle (SRP): Each class and function should have one clear purpose. Decompose large classes if they handle multiple distinct responsibilities.
Descriptive Naming: Use names that clearly state the intent of the variable, function, or class. Avoid cryptic abbreviations.
Function Size: Aim for small, focused functions. If a function is too long, extract sub-functions.
DRY (Don’t Repeat Yourself): Extract common logic into helper methods or utility classes.
Constant Extraction: Avoid hardcoded strings or numbers. Extract them into meaningful constants.
Comments: Write code that is self-documenting. Use comments only to explain “why” something is done if it’s not obvious from the “what” and “how”.