I started working on a project and I saw some methods with this With prefix and I'm wondering if this refers to a known pattern.
Does anyone know of this naming pattern?
I've seen a with prefix used in a couple of different ways that may be similar to what's being done in the codebase you're working on.
var myobj = MyObj.builder() .withProperty1("property 1 value") .withProperty2("property 2 value") .build(); var myImmutableObj = new MyImmutableObj("property 1 value", "property 2 value"); var myImmutableObjClone = myImmutableObj.withProperty1("different property 1 value");
voidand simply set fields (essentially setters); and B) methods that set fields and returnsthis.