Skip to content

Conversation

@burgbart
Copy link
Collaborator

Architectural alignment journey

  • Move UseCase implementation into the journey package
  • Remove domain models and mappers

implementations in to the journey and to not make use of a domain model
anymore
companion object {
const val ACCOUNT_NAME = "Alpha"
const val ACCOUNT_BALANCE = "45.89"
val ACCOUNT_BALANCE = BigDecimal.valueOf(45.89)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has potential precision and unchecked nullability issues. Better to use BigDecimal("45.89") to be exact.

import com.backbase.android.client.gen2.arrangementclient2.model.AccountArrangementItem
import dev.drewhamilton.poko.Poko

interface AccountDetailUseCase {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
interface AccountDetailUseCase {
fun interface GetAccountDetailUseCase {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend this change to enforce the SAM nature of this use-case and name it accordingly.


interface AccountDetailUseCase {
suspend fun getAccountDetail(params: Params): Result<AccountDetail>
suspend fun getAccountDetail(params: Params): Result<AccountArrangementItem>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
suspend fun getAccountDetail(params: Params): Result<AccountArrangementItem>
suspend operator fun invoke(params: Params): Result<AccountArrangementItem>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operator is also a nice addition here to allow:

val getAccountDetails = GetAccountDetailUseCase { params ->
   ...
}

getAccountDetails(Params{})

* @return an instance of [ProductSummary]
*/
suspend fun getAccountSummary(useCache: Boolean = true): Result<AccountSummary>
suspend fun getAccountSummary(useCache: Boolean = true): Result<ProductSummary>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
suspend fun getAccountSummary(useCache: Boolean = true): Result<ProductSummary>
suspend operator fun invoke(useCache: Boolean = true): Result<ProductSummary>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same recommendations as AccountDetailUseCase


interface AccountDetailUseCase {
suspend fun getAccountDetail(params: Params): Result<AccountDetail>
suspend fun getAccountDetail(params: Params): Result<AccountArrangementItem>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still not convinced about exposing client objects directly with the journey's APIs. We risk unnecessarily coupling the client API with journey's API. Clients are generated and inherently produce unstable(especially from past experience) API that strongly tied to the BE. I am not sure it's prudent to strongly couple the 2.

Also keep in mind that for certain BE capabilities, their models don't map 1-to-1 to UI models . BE models will still need some mapping/transformation in the journey in some cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants