Skip to content

Rethink the setters paradigm #91

Open
@xibz

Description

@xibz

Setters are not heavily used in Go, so we should revisit a more idiomatic approach either by setting things on the struct directly or using functions options which is pretty standard in Go

So instead of

event := cdevents.NewSomeCDEvent()
event.SetFoo("foo")

we'd have something more like

event := cdevents.NewSomeCDEvent(cdevent.SomeCDEventOptions.WithFields(func(e cdevents.SomeCDEvent) {
    e.Foo = "foo"
})

// or
event := cdevents.NewSomeCDEvent(cdevent.SomeCDEventOptions.WithFoo("foo"))

Or a combination of the two. So is one better than the other? Not necessarily. But one is more idiomatic, and that's crucial for SDKs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions