Is it acceptable for a `useCase` to have multiple ...
# android
v
Is it acceptable for a
useCase
to have multiple methods that are called inside the
invoke()
block and that serve the final purpose of the said use case? For example, a use case responsible for rendering a template having a method to retrieve the template from a backend or assets and another method for filling it out with values
not kotlin but kotlin colored 2
Copy code
class RenderTemplateUseCase @Inject constructor(
    private val templateRepository: TemplateRepository
) {
    suspend fun invoke(templateId: String, values: Map<String, Any>): String {
        val template = retrieveTemplate(templateId)
        return fillTemplate(template, values)
    }

    private suspend fun retrieveTemplate(id: String): String {
        return templateRepository.getTemplate(id)
    }

    private fun fillTemplate(template: String, values: Map<String, Any>): String {
        // Template filling logic
    }
}
b
Why not?