Thomas Martin
08/01/2024, 1:37 PMBlaž Vantur
08/01/2024, 1:43 PMThomas Martin
08/01/2024, 1:46 PMBlaž Vantur
08/01/2024, 2:00 PMCLOVIS
08/01/2024, 2:05 PMKlitos Kyriacou
08/01/2024, 3:25 PMDossierForSearch
a data class already? Then you wouldn't need such a function.Thomas Martin
08/01/2024, 3:45 PMThomas Martin
08/01/2024, 3:47 PMShaun Burch
08/02/2024, 1:32 AMfun build(
dossier: DossierOutput,
workspace: WorkspaceOutput,
clock: Clock,
owner: TalentOutput? = null,
account: AccountOutput? = null,
parentAccount: AccountOutput? = null,
project: ProjectExtended? = null,
activities: Collection<ActivityOutput> = emptyList(),
tasks: Collection<TaskOutput> = emptyList(),
): DossierForSearch
// Minimal
DossierForSearchBuilder.build(
dossier = dossier,
workspace = workspace,
clock = clock,
)
Or group some associated params into smaller data classes? (Hard to infer from signature, but hopefully illustrates)
fun build(
clock: Clock,
outputs: Outputs,
project: ProjectExtended? = null,
): DossierForSearch
data class Outputs(
dossier: DossierOutput,
workspace: WorkspaceOutput,
owner: TalentOutput? = null,
account: AccountOutput? = null,
parentAccount: AccountOutput? = null,
activities: Collection<ActivityOutput> = emptyList(),
tasks: Collection<TaskOutput> = emptyList(),
)
DossierForSearchBuilder.build(
clock = clock,
outputs = Outputs(
dossier = DossierOutput,
workspace = WorkspaceOutput,
),
project = project
)
Thomas Martin
08/02/2024, 7:11 AMThomas Martin
08/02/2024, 7:15 AMCreating objects using a primary constructor is the most appropriate approach for the vast majority of objects in our projects. Telescoping constructor patterns should be treated as obsolete in Kotlin. I recom- mend using default values instead, as they are cleaner, more flexible, and more expressive. The classic builder pattern is rarely reasonable. In simpler cases we can just use a primary constructor with named arguments, and when we need to create more complex object we can define a DSL builder for that.
Thomas Martin
08/02/2024, 7:15 AMCLOVIS
08/02/2024, 7:18 AMShaun Burch
08/02/2024, 12:08 PMmy question is why ?
human reviewer told me there are too many paramsIt comes down to who the users of that code will be. Do they find a large signature which is not using default params excessive to work with. But that’s between you and your team to decide.
Thomas Martin
08/02/2024, 12:38 PMShaun Burch
08/02/2024, 1:56 PMKhalil Elias
08/02/2024, 5:04 PM