Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

A recipe for the Perfect Use Case

DEV Community·numq·19 days ago
#aVldHY26
Reading 0:00
15s threshold

Today we’re cooking the perfect Use Case — and CQRS will be our recipe. Ingredients Action — fire and forget (logout, clear cache) Query — read data (list products) Command — write data (update profile) Exchange — transform data (login) All four types extend a sealed interface: sealed interface UseCase < Input , Output > { class Action : UseCase < Unit , Unit > class Query < Output > : UseCase < Unit , Output > class Command < Input > : UseCase < Input , Unit > class Exchange < Input , Output > : UseCase < Input , Output > } Enter fullscreen mode Exit fullscreen mode Three Ways to Season It Arrow (Typed Errors) — the chef’s choice: class GenerateSeed ( private val seedService : SeedService ) : UseCase . Action { override suspend fun Raise < Throwable >. action () = seedService . generateSeed ().…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More