You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-8Lines changed: 11 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,19 +12,20 @@ but try to avoid the more advanced FP features that don't translate well to Kotl
12
12
## Opinions
13
13
14
14
* No dependency injection. You simply do not need it.
15
-
*It is trivial to pass dependencies through the constructor. Services should be small enough that you don't have
16
-
layers upon layers of "services" where passing dependencies around becomes a burden.
15
+
*In Kotlin, it is trivial to pass dependencies through the constructor. Services should be small enough that you don't have
16
+
a dozen layers of serviceX calling serviceY calling serviceZ, where passing dependencies becomes a layer cake.
17
17
* When you use constructors as they were intended, you never have to try and work out where a "bean" is being
18
18
instantiated.
19
+
* You'll get a compile error if anything is not wired up. As it should be.
19
20
* Config as data classes.
20
-
* Easy to test because you can simply create the config values you want in tests and pass in an instance of the data
21
-
class.
21
+
* Easy to test because you can simply create an instance of the data class with whatever values you want to use in a test and pass that into the class.
22
22
* No confusion as to where values are being pulled from.
23
+
* Startup time resolution on mapping config values to strongly typed values.
23
24
* Tests should be real tests
24
-
* No mocks. Ever. You don't need them (caveat - you might need them in some tiny edge cases, like testing a legacy
25
-
Java interface with 200 methods).
26
-
* Test your endpoints by using a framework that treats requests as simple objects.
27
-
* Use [test containers](https://testcontainers.com/)for real databases.
25
+
* No mocks. Ever. You don't need them (caveat - ok you might need them in some tiny edge cases, like testing a legacy
26
+
Java interface with 200 methods when you don't want to create an implementation).
27
+
* Test your endpoints by using a framework that treats requests as objects.
28
+
* Use [test containers](https://testcontainers.com/)to test against real infrastructure like postgres, kafka, redis, etc. Then you know your SQL will work instead of mocking it out.
28
29
* Use embedded HTTP servers for upstream dependencies.
29
30
* Functional error handling
30
31
* Don't throw exceptions unless it's truly exceptional. Expected errors, such as invalid json, are not exceptional.
@@ -41,6 +42,8 @@ but try to avoid the more advanced FP features that don't translate well to Kotl
41
42
* Spring JDBC Template is a simple set of helpers around JDBC calls that will handle injection projection and transaction support and mapping results back to classes without needing to jump through hoops.
42
43
* Don't use Strings for all your types
43
44
* Avoid so called stringy-typed development.
45
+
* Use value objects for extra type safety
46
+
* You can create `data class Height(val value: Int)` and pass that about. Yes it's another object to be instantiated. No you're never going to see a performance impact because your webapp is spending all its time in IO anyway.
0 commit comments