4 ms·
> Some of those ways come from just plain object initialisers. Which are amazing and sorely needed in Java. They really aren't, and they are IMHO an antipatter
by samus 18d ago
> Some of those ways come from just plain object initialisers. Which are amazing and sorely needed in Java.
They really aren't, and they are IMHO an antipattern since they break encapsulation. One might argue that encapsulation doesn't matter with mere data classes, but Java will cater to that use case by introducing withers.
- troupo 18d ago> They really aren't, and they are IMHO an antipattern since they break encapsulation. They don't. Java had to come up with the extremely verbose builder pattern for the exact same thing. And withers are basically the same tedious manual builder pattern, just with a different name. For withers C# just has the with keyword: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/with-expression https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...