Skip to content

Implement abstract "with-" methods in the value classΒ #294

Closed
@kevinb9n

Description

@kevinb9n

It is a somewhat well-known pattern that a "withPropertyName(...)" method in an immutable class returns a copy of that instance with only that one property changed.

Users can write these themselves, but:

  • It's really gross if you're not using the builder option
  • It's also gross just that there are two different ways you have to do it based on whether you use a builder or not
  • And we should note that even in the best case, where you use your own builder, a builder will be allocated and thrown away somewhat unnecessarily

We could add a feature saying that you can define these "with-er" methods as abstract methods and AV will implement them.

But.... if this is a feature that 1% of all value classes will ever use, I'd probably prefer we hadn't bothered with it. (Though granted, it's not the kind of feature that means more documentation; we feel the with- example needs to be documented either way so it actually simplifies the docs.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions