Skip to main content

Questions tagged [immutability]

Immutability is about having objects that cannot be changed.

4 votes
2 answers
2k views

I've read somewhere about a pattern that is as follows: if it'll change the state of the instance, the method should be named with a verb and return void; and if the method just returns something (...
Bernardo Benini Fantin's user avatar
0 votes
1 answer
300 views

Lombok is used in the legacy project where I am currently working for since last year. The project is legacy with 10+ years, and POJO/JavaBeans, i.e. @Data annotated classes, have been widely used for ...
Rui's user avatar
  • 1,935
1 vote
5 answers
398 views

Edit: I'm copying the question but changing the example code. Apparently, I used a bad example earlier that contained an imprue getter. I'm keeping the old example code at the bottom so the first ...
sharbel okzan's user avatar
6 votes
2 answers
1k views

While I was learning functional programming I have encounterd two for me very similar terms: immutability and persistence. Also I have read simular questions from stackoverflow, but I am still ...
DimitrijeCiric's user avatar
10 votes
9 answers
4k views

The most popular answer is - it is an object whose state does not change after creation. What does it actually mean? My understanding is that any method call on the object should give the same result. ...
kan's user avatar
  • 402
8 votes
2 answers
2k views

I am looking at the List<T>.AsReadOnly() method. Since List<T> itself is a IReadOnlyCollection<T>. (It implements IReadOnlyList<T> and IReadOnlyList<T> implements ...
Madushan's user avatar
  • 233
16 votes
6 answers
7k views

I've heard people say things like "B can't inherit from A because A is immutable and B is mutable". My understanding of inheritance in Object-Oriented Programming is that you use it to add ...
GlenPeterson's user avatar
1 vote
3 answers
2k views

Is it a good idea to mark a function const from clean code perspective if it change other objects' states? I'd like to know what is the experience with this or is it considered a bad practice for any ...
66Gramms's user avatar
  • 129

15 30 50 per page
1
2 3 4 5
12