# databricks/scala-style-guide

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/databricks-scala-style-guide).**

2,784 stars · 585 forks

## Links

- GitHub: https://github.com/databricks/scala-style-guide
- awesome-repositories: https://awesome-repositories.com/repository/databricks-scala-style-guide.md

## Tags

### Web Development

- [Java Interop Conventions](https://awesome-repositories.com/f/web-development/scala/java-interop-conventions.md) — Provides guidelines for writing Scala code that remains callable and idiomatic from Java.
- [NonFatal](https://awesome-repositories.com/f/web-development/exception-handling/nonfatal.md) — Enforces catching only NonFatal exceptions to avoid swallowing critical control flow errors. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Java-Only Feature Definitions](https://awesome-repositories.com/f/web-development/java/java-only-feature-definitions.md) — Defines static fields, inner classes, enums, and annotations in Java files when needed for Java interop. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))

### Part of an Awesome List

- [Case Class Immutability](https://awesome-repositories.com/f/awesome-lists/devtools/immutable-data-structures/immutability-converters/immutable-value-class-generators/case-class-immutability.md) — Defines case classes with immutable constructor parameters and uses the copy constructor for changes to prevent hash-related bugs. ([source](https://github.com/databricks/scala-style-guide#readme))
- [CamelCase Naming Rules](https://awesome-repositories.com/f/awesome-lists/devtools/naming-conventions/camelcase-naming-rules.md) — Names variables and methods in camelCase with self-evident names for readability. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Symbolic Method Name Restrictions](https://awesome-repositories.com/f/awesome-lists/devtools/pattern-matching/code-naming-patterns/method-naming-patterns/symbolic-method-name-restrictions.md) — Restricts operator overloading to natural arithmetic operations like +, -, *, /. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Infix Notation Restrictions](https://awesome-repositories.com/f/awesome-lists/devtools/pattern-matching/code-naming-patterns/method-naming-patterns/symbolic-method-name-restrictions/infix-notation-restrictions.md) — Limits infix notation to symbolic operator methods only, avoiding it for regular named methods. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Call-by-Name Parameter Avoidance Rules](https://awesome-repositories.com/f/awesome-lists/devtools/pattern-matching/code-naming-patterns/parameter-naming/call-by-name-parameter-avoidance-rules.md) — Replaces call-by-name parameters with explicit `() => T` function types to clarify execution semantics. ([source](https://github.com/databricks/scala-style-guide#readme))

### Data & Databases

- [Synchronization Mechanism Selections](https://awesome-repositories.com/f/data-databases/client-server-data-synchronization/preference-synchronization/synchronization-mechanism-selections.md) — Chooses between ConcurrentHashMap, synchronizedMap, or explicit synchronization based on contention. ([source](https://github.com/databricks/scala-style-guide#readme))
- [ConcurrentHashMap Preferences](https://awesome-repositories.com/f/data-databases/key-value-pair-managers/concurrent-map-implementations/concurrenthashmap-preferences.md) — Prefers Java ConcurrentHashMap over Scala's concurrent map to avoid non-atomic getOrElseUpdate. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Loop Over Recursion Preferences](https://awesome-repositories.com/f/data-databases/recursive-structure-processors/recursive-structure-traversers/loop-over-recursion-preferences.md) — Uses imperative loops and state machines instead of recursion, except for naturally recursive problems like tree traversal. ([source](https://github.com/databricks/scala-style-guide#readme))

### Development Tools & Productivity

- [Spacing and Indentation Rules](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/code-formatting-tools/indentation-settings/spacing-and-indentation-rules.md) — Defines 2-space indentation and spacing rules for consistent Scala code formatting. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Import Organizers](https://awesome-repositories.com/f/development-tools-productivity/import-organizers.md) — Groups imports by origin (Java, Scala, third-party, project) for clarity and navigation. ([source](https://github.com/databricks/scala-style-guide#readme))

### Education & Learning Resources

- [Import Grouping Conventions](https://awesome-repositories.com/f/education-learning-resources/import-conventions/import-grouping-conventions.md) — Sorts imports by package origin (Java, Scala, third-party, project) and avoids wildcards beyond six entities. ([source](https://github.com/databricks/scala-style-guide#readme))

### Networking & Communication

- [Consistent Synchronization Strategies](https://awesome-repositories.com/f/networking-communication/distributed-state-synchronization/consistent-synchronization-strategies.md) — Uses one synchronization mechanism consistently without mixing ConcurrentHashMap, synchronizedMap, or explicit blocks. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [URI Over URL Preferences](https://awesome-repositories.com/f/networking-communication/service-address-resolution/uri-over-url-preferences.md) — Stores service addresses as URI to avoid blocking network calls during equality checks. ([source](https://github.com/databricks/scala-style-guide#readme))

### Operating Systems & Systems Programming

- [Atomic Variable Preferences](https://awesome-repositories.com/f/operating-systems-systems-programming/lock-free-atomic-containers/atomic-variable-preferences.md) — Prefers java.util.concurrent.atomic classes over @volatile for lock-free access to single variables. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))

### Programming Languages & Runtimes

- [Override Enforcement](https://awesome-repositories.com/f/programming-languages-runtimes/class-method-overrides/override-enforcement.md) — Marks every method override with the `override` keyword, including implementations of abstract methods. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Java Interop Overloading Practices](https://awesome-repositories.com/f/programming-languages-runtimes/function-parameter-handling/java-interop-overloading-practices.md) — Use method overloading instead of default parameter values to maintain compatibility with Java callers. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Implicit Usage Restrictions](https://awesome-repositories.com/f/programming-languages-runtimes/implicit-type-casting/implicit-usage-restrictions.md) — Restricts implicit usage to DSLs and type tags, a key Scala style rule in this guide. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [API Design for Java Consumers](https://awesome-repositories.com/f/programming-languages-runtimes/java-annotation-processors/varargs-annotation-for-java-interop/api-design-for-java-consumers.md) — Designs Scala APIs that are accessible and idiomatic for Java callers through overloading and abstract classes.
- [Multiple Parameter List Avoidance](https://awesome-repositories.com/f/programming-languages-runtimes/java-annotation-processors/varargs-annotation-for-java-interop/api-design-for-java-consumers/implicit-parameter-restrictions/multiple-parameter-list-avoidance.md) — Does not use multiple parameter lists except for implicit parameters in low-level libraries. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Documentation Comment Styles](https://awesome-repositories.com/f/programming-languages-runtimes/javadoc-generation/documentation-comment-styles.md) — Uses JavaDoc-style comments instead of ScalaDoc for documentation. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Private Field Access Restrictions](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/concurrency-models/concurrency/thread-local-contexts/thread-safe-synchronization-contexts/private-field-access-restrictions.md) — Marks fields as private[this] to prevent access from other instances and ensure safe synchronization. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Public Method Annotations](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/type-system-tools/type-safety/explicit-variable-typing/public-method-annotations.md) — Requires explicit return types on public methods and non-obvious variables to improve code readability and safety.
- [Monadic Pipelines](https://awesome-repositories.com/f/programming-languages-runtimes/monadic-pipelines.md) — Keeps monadic chains short and breaks them after flatMap to improve readability. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [API Design Rules](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/jvm-languages/scala/api-design-rules.md) — Provides a set of rules for designing clear and Java-interoperable Scala public APIs.
- [Concurrency Patterns](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/jvm-languages/scala/concurrency-patterns.md) — Provides a set of concurrency patterns for writing thread-safe Scala code using explicit synchronization and atomic variables.
- [Performance Guidelines](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/jvm-languages/scala/performance-guidelines.md) — Provides a set of performance guidelines for optimizing Scala code using Java collections and while loops.
- [Performance Optimization Guidelines](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/jvm-languages/scala/performance-optimization-guidelines.md) — Provides a comprehensive set of performance optimization guidelines for writing high-performance Scala code.
- [Java Interop](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-execution-environments/runtime-environments/runtimes/type-definition-systems/abstract-classes/java-interop.md) — Prefer abstract classes over traits with default implementations to ensure Java code can extend them. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Comprehensive Interop Conventions](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-execution-environments/runtime-environments/runtimes/type-definition-systems/abstract-classes/java-interop/comprehensive-interop-conventions.md) — Defines a comprehensive set of conventions for making Scala APIs seamlessly callable from Java.
- [Java Interop Restrictions](https://awesome-repositories.com/f/programming-languages-runtimes/type-aliasing/java-interop-restrictions.md) — Omit type aliases from public APIs because they are invisible in bytecode and inaccessible from Java. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Java Microbenchmarking Harnesses](https://awesome-repositories.com/f/programming-languages-runtimes/c-microbenchmarking-libraries/java-microbenchmarking-harnesses.md) — Recommends using the Java Microbenchmark Harness for accurate performance measurement in Scala. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Apply Method Restrictions](https://awesome-repositories.com/f/programming-languages-runtimes/class-method-definitions/apply-method-restrictions.md) — Defines apply methods only on companion objects as factory methods returning the companion class type. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Constructor Destructuring Prohibitions](https://awesome-repositories.com/f/programming-languages-runtimes/destructuring-assignments/destructuring-style-enforcement/constructor-destructuring-prohibitions.md) — Does not use tuple destructuring in class constructors to prevent non-transient fields. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Implicit Parameter Restrictions](https://awesome-repositories.com/f/programming-languages-runtimes/java-annotation-processors/varargs-annotation-for-java-interop/api-design-for-java-consumers/implicit-parameter-restrictions.md) — Does not use implicit parameters, including ClassTag and TypeTag, in methods intended for Java callers. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Java Collection Extensions](https://awesome-repositories.com/f/programming-languages-runtimes/java-collection-extensions.md) — Recommends using Java collections over Scala collections in performance-sensitive code to reduce overhead. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Scala Performance Preferences](https://awesome-repositories.com/f/programming-languages-runtimes/java-collection-extensions/scala-performance-preferences.md) — Recommends using Java collections over Scala collections in performance-sensitive code to reduce overhead. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Loop Optimizations](https://awesome-repositories.com/f/programming-languages-runtimes/loop-optimizations.md) — Recommends using while loops over for loops or functional transformations in performance-sensitive code. ([source](https://github.com/databricks/scala-style-guide#readme))
- [While Loop Preferences](https://awesome-repositories.com/f/programming-languages-runtimes/loop-optimizations/while-loop-preferences.md) — Recommends using while loops over for loops or functional transformations in performance-critical code. ([source](https://github.com/databricks/scala-style-guide#readme))

### Security & Cryptography

- [Style Enforcement Conventions](https://awesome-repositories.com/f/security-cryptography/source-code-vulnerability-scanning/scala-source-code-scanners/style-enforcement-conventions.md) — Enforces consistent coding conventions across a Scala codebase to improve readability and maintainability.

### Software Engineering & Architecture

- [Method and Class Size Limits](https://awesome-repositories.com/f/software-engineering-architecture/code-complexity-metrics/method-count-limits/method-and-class-size-limits.md) — Limits methods to fewer than 30 lines and classes to fewer than 30 methods to reduce complexity. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Scala Style Guides](https://awesome-repositories.com/f/software-engineering-architecture/code-style-guides/scala-style-guides.md) — Ships a comprehensive Scala style guide that prioritizes Java interoperability, readability, and performance.
- [Encapsulated Synchronization Modules](https://awesome-repositories.com/f/software-engineering-architecture/concurrency-synchronization-primitives/encapsulated-synchronization-modules.md) — Encapsulates synchronization primitives in small inner modules to keep APIs free of concurrency details. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Naming Conventions](https://awesome-repositories.com/f/software-engineering-architecture/development-methodologies/engineering-best-practices/code-craftsmanship-standards/coding-standards/naming-conventions.md) — Defines PascalCase for classes and traits, camelCase for methods and variables, and uppercase for constants to ensure consistent code style. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Chaining Length Limits](https://awesome-repositories.com/f/software-engineering-architecture/optional-value-types/operation-chaining/chaining-length-limits.md) — Keeps chained operations to three or fewer and breaks chains after `flatMap` to preserve readability. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Option for Nullable Values](https://awesome-repositories.com/f/software-engineering-architecture/optional-value-types/option-for-nullable-values.md) — Mandates wrapping nullable values in Option to make emptiness explicit and prevent null pointer exceptions. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Performance Optimization Patterns](https://awesome-repositories.com/f/software-engineering-architecture/performance-optimization-patterns.md) — Provides guidelines for using while loops over for loops to avoid iterator allocation in performance-critical code. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Line Length Limits](https://awesome-repositories.com/f/software-engineering-architecture/source-file-organization/file-length-limits/line-length-limits.md) — Caps source lines at 100 characters, with exceptions only for import statements and URLs. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Blank Line Formatting Rules](https://awesome-repositories.com/f/software-engineering-architecture/code-complexity-metrics/source-statement-metrics/line-counting/blank-line-formatting-rules.md) — Separates class members and logical groups with single blank lines to improve readability. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Library Reuse Preferences](https://awesome-repositories.com/f/software-engineering-architecture/library-reuse-preferences.md) — Prefers existing tested implementations over reimplementing logic to reduce bugs. ([source](https://github.com/databricks/scala-style-guide#readme))
- [nanoTime Usage](https://awesome-repositories.com/f/software-engineering-architecture/monotonic-time-measurement/nanotime-usage.md) — Mandates using System.nanoTime() for timing and timeouts to avoid wall-clock adjustment issues. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Throughput Measurement](https://awesome-repositories.com/f/software-engineering-architecture/monotonic-time-measurement/throughput-measurement.md) — Mandates using System.nanoTime() for duration measurement to avoid wall-clock adjustment issues. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Training Duration Measurements](https://awesome-repositories.com/f/software-engineering-architecture/monotonic-time-measurement/training-duration-measurements.md) — Mandates using System.nanoTime() for duration and timeout measurement to avoid wall-clock adjustment issues. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
- [Null Preferences for Performance](https://awesome-repositories.com/f/software-engineering-architecture/optional-value-types/option-for-nullable-values/null-preferences-for-performance.md) — Recommends using null over Option in performance-critical paths to avoid boxing overhead. ([source](https://github.com/databricks/scala-style-guide#readme))
- [Hot Path Optimizations](https://awesome-repositories.com/f/software-engineering-architecture/performance-reliability/code-optimization/hot-path-optimizations.md) — Optimizes hot code with while loops, private[this] fields, and null over Option to reduce allocation and boxing overhead.
- [Utility Reuse Preferences](https://awesome-repositories.com/f/software-engineering-architecture/utility-reuse-preferences.md) — Prefers existing library methods like TimeUnit over reimplementing common conversions. ([source](https://github.com/databricks/scala-style-guide#readme))

### Testing & Quality Assurance

- [Exception Assertions](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/assertions-and-validation/assertion-validation-utilities/assertion-libraries/execution-assertions/exception-assertions.md) — Ships a style guide that mandates asserting exact exception types in tests rather than catching generic exceptions. ([source](https://github.com/databricks/scala-style-guide#readme))

### User Interface & Experience

- [Method Parenthesis Conventions](https://awesome-repositories.com/f/user-interface-experience/component-property-systems/property-validation/property-accessor-methods/method-parenthesis-conventions.md) — Declares methods with parentheses unless they are side-effect-free accessors. ([source](https://github.com/databricks/scala-style-guide/blob/master/README.md))
