Skip to content

Commit

Permalink
No interface if only one implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
BBB committed Jul 19, 2023
1 parent e7d7752 commit b9b0350
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/me/relph/application/Launcher.kt
@@ -1,10 +1,10 @@
package me.relph.application

import me.relph.domain.hub.HubImpl
import me.relph.domain.hub.Hub
import me.relph.domain.adapter.InMemoryUserStorage

fun main() {
val hub = HubImpl(InMemoryUserStorage())
val hub = Hub(InMemoryUserStorage())
val server = HexHttpServer(hub)

server.start()
Expand Down
12 changes: 12 additions & 0 deletions src/main/kotlin/me/relph/domain/hub/Hub.kt
@@ -0,0 +1,12 @@
package me.relph.domain.hub

import dev.forkhandles.result4k.*
import me.relph.domain.port.UserStorage

typealias UserId = String

class Hub(private val users: UserStorage) {
fun greet(userId: UserId) = users.byId(userId).map{"hello ${it.name}"}.flatMapFailure { Success("hello anon") }
fun ping() = Success("pong")
}

13 changes: 0 additions & 13 deletions src/main/kotlin/me/relph/domain/hub/HubImpl.kt

This file was deleted.

9 changes: 0 additions & 9 deletions src/main/kotlin/me/relph/domain/port/Hub.kt

This file was deleted.

4 changes: 2 additions & 2 deletions src/test/kotlin/me/relph/domain/hub/HubImplTest.kt
Expand Up @@ -9,7 +9,7 @@ import strikt.assertions.isEqualTo

internal class HubImplTest {

private val hub = HubImpl(InMemoryUserStorage())
private val hub = Hub(InMemoryUserStorage())

@Test
fun `can ping`() {
Expand All @@ -19,4 +19,4 @@ internal class HubImplTest {
fun `can greet an unknown user`() {
expectThat(hub.greet("xxx")).isEqualTo(Success("hello anon"))
}
}
}

0 comments on commit b9b0350

Please sign in to comment.