Skip to main content

Questions tagged [mutable]

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
4 votes
2 answers
3k views

I have some incoming request - it's an instance of class generated from api specification - POJO with public getters/setters. I would like to normalize some values. For example dimensions (to use ...
Shaolin's user avatar
  • 43
2 votes
0 answers
119 views

None of my team's programs care about multithreading, parallelisation, async, or anything else that benefit from immutability. However, immutability is clearly in fashion at the moment and I'm ...
J. Mini's user avatar
  • 1,015
7 votes
1 answer
540 views

I am reading through "Clean Architecture: A Craftsman's Guide to Software Structure and Design" and it says that: All race conditions, deadlock conditions, and concurrent update problems are ...
Quantum Guy 123's user avatar
0 votes
1 answer
166 views

I'm very new to writing immutable code. Would there be any fundamental issues trying to transpile arbitrary mutable code person.age = 20 into immutable code person = { ...person, age: 21 }? I am aware ...
phil-daniels's user avatar
5 votes
3 answers
736 views

I feel this is a bad question because I probably do not understand what I am talking about. In my effort to learn about functional programming, I became stumped on understanding the idea of immutable ...
Julian's user avatar
  • 77
0 votes
4 answers
804 views

I know the fact that global mutable variables are bad as they can be accidentally modified and make testing difficult. However, there are situations when a class needs to cache some information, for e....
Navjot Singh's user avatar
1 vote
2 answers
730 views

I have come across mutable variables kind often, yet it seems to me it's always been use to solve a problem of design(typically coping with legacy code) rather than to answer a natural, intrinsic ...
stackoverflower's user avatar
8 votes
4 answers
5k views

I recently came across Herb Sutter's video from about how the meaning of const and mutable has changed in C++11 to mean bitwise const (and thread-safe, as a consequence) instead of the traditional ...
CK.'s user avatar
  • 197
5 votes
1 answer
454 views

I am writing a type checker for an ML dialect that involves generating "fresh" (new and unique) "type variables" (values representing unknowns). My strategy, and the strategy that seems to be used in ...
Del's user avatar
  • 161
5 votes
1 answer
2k views

The following code snippets are simplified to demonstrate the context! The actual interfaces and classes are POCOs having additional properties. The types are part of library I am working on, the ...
ckerth's user avatar
  • 51
0 votes
2 answers
117 views

When I design the architecture of an application, I usually think about the nature of the objects and the interactions between them. The way I currently think about mutability is to ask myself if ...
Paul92's user avatar
  • 2,631
6 votes
1 answer
7k views

Some Explanation I'm somewhat new to python and to programming (I've been at it for a little over a year). I just recently discovered python properties, and I've been using them to limit the ...
Josie Thompson's user avatar
0 votes
1 answer
168 views

I started questioning what I know, or thought that I know, after this question: Array.fill differs from literal 2D definition on assignment A JavaScript question, defining an array with predefined ...
ASertacAkkaya's user avatar
59 votes
3 answers
44k views

Suppose I have a stream of Things and I want to "enrich" them mid stream, I can use peek() to do this, eg: streamOfThings.peek(this::thingMutator).forEach(this::someConsumer); Assume that ...
Bohemian's user avatar
  • 2,076

15 30 50 per page