-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Service method signatures #59
Comments
Updated proposal for the method signature: fun create(param: CreateParam): Result<Event> Many of the entities contain as many or more properties as data class CreateParam(
id: UUID? = null,
name: String,
date: LocalDate,
crispyFish: Event.CrispyFishMetadata?,
motorsportReg: Event.MotorsportRegMetadata?,
policy: Policy
) Notice this parameter excludes Changing the return type to It would also be nice to adopt a standard interface CrudService<Entity, CreateParam, ReadParam, UpdateParam, DeleteParam> {
suspend fun create(param: CreateParam): Result<Entity>
suspend fun read(param: ReadParam): Result<Entity>
suspend fun update(param: UpdateParam): Result<Entity>
suspend fun delete(param: DeleteParam): Result<Unit>
} At time of writing, all of the services are just classes which loosely (inconsistently) follow pretty similar conventions, but there are definitely some outliers. Having some standardization would make them easier to work on, and simplify mocking. There should also be a separate interface for services that support listing entities. This would be good to do in conjunction with #58. Example: interface ListService<Entity> {
suspend fun list(): Result<List<Entity>>
} Breaking this out separately from the |
Most current io module
Service
class methods follow the below pattern, not limited tocreate
methods:This causes users of the Service classes to take on too much responsibility for creation, mutation, etc of the entities. That logic belongs in the Service classes, not scattered around various UIs.
Proposal based on recent refactor of
EventService
:The text was updated successfully, but these errors were encountered: