Many developers who started their careers with OOP may not realize the flaws in traditional getter-setter pattern. This pattern, although ingrained due to indoctrination with OOP, creates issues with mutability and state, complicating code understanding. By embracing immutability, the code becomes easier to reason about. Implementing the with pattern and Builder pattern can further enhance code clarity and maintainability. While there are situations where mutability is necessary, keeping mutable classes small and dropping unnecessary getters and setters can improve code quality. Erasing the getter-setter anti-pattern from our minds will lead to less error-prone, concurrency-friendly, and easier-to-read code.
https://wolfgang-ziegler.com/blog/getter-setter-pattern-considered-harmful