Skip to content

Commit f43cc02

Browse files
committed
Avoid default parameters
1 parent 4c00aad commit f43cc02

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Rules in **bold** are the most important ones.
2424
- [PREFER] Use value classes when possible
2525
- [PREFER] Do not use `lazy`
2626
- [MUST] Do not pattern match on `Throwable`, use `NonFatal(e)`
27+
- [[PREFER] Do not use default parameters](guidelines/scala/avoid-default-parameters.md)
2728
1. Functional programming
2829
- **[PREFER] Use pure functions as much as possible**
2930
- [PREFER] By default, use immutable values
@@ -58,3 +59,4 @@ They are here just as a source of inspiration, they are not included in our guid
5859
- [Databricks best practices](https://github.com/databricks/scala-style-guide)
5960
- [PayPal best practices](https://github.com/paypal/scala-style-guide)
6061
- [Twitter best practices](http://twitter.github.io/effectivescala)
62+
- [Why are Default Parameter Values Considered Bad in Scala?](https://blog.ssanj.net/posts/2019-05-01-why-are-default-parameter-values-considered-bad-in-scala.html)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Avoid default parameters
2+
Default parameters are convenient but have a number of issues:
3+
- Unclear code
4+
- Hard to use currying and partial application
5+
- Subtle bugs that would be otherwise catched by the compiler
6+
7+
See [https://blog.ssanj.net/posts/2019-05-01-why-are-default-parameter-values-considered-bad-in-scala.html]

guidelines/scala/do-not-abuse-of-primitive-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Do not abuse of primitive types
22

3-
This is a well known code small named [Primitive Obsession](https://www.franzoni.eu/primitive-types-are-not-your-friends/), often due to developer laziness.
3+
This is a well known code smell named [Primitive Obsession](https://www.franzoni.eu/primitive-types-are-not-your-friends/), often due to developer laziness.
44

55
When you manipulate a lot of `String`, `Int` or `Boolean`, it becomes harder and harder to know what they contain and do not make mistakes manipulating them.
66

0 commit comments

Comments
 (0)