The immutability tag has no wiki summary.
5
votes
2answers
230 views
Is Haskell/Clojure actually unsuited for dynamic systems such as particle simulation?
I've been told in previous questions that functional programming languages are unsuited for dynamic systems such as a physics engine, mainly because it's costly to mutate objects. How realistic is ...
-1
votes
4answers
188 views
Immutable vs mutable object as returned parameter for class method [closed]
There is a class method (static method) in which I create and build some object. And for filling that object, I create it as mutable object.
My mutable object is a subclass of immutable object. So ...
5
votes
2answers
331 views
When is it inappropriate to make objects immutable?
I have a class which represents an entity object in our system (for sake of argument, a Customer object)
public class Customer()
{
private int id;
private String name;
... // 30+ fields
...
5
votes
2answers
160 views
method to allow me ability to freely modify my classes, but make them immutable to others?
I am creating the model part of an MVC architecture. My one class will provide all the accesses to allow one to fetch system state. I want most of this state to be immutable as it shouldn't be ...
3
votes
5answers
544 views
When and why would we use immutable pointers?
In Java, the String object is both immutable and also a pointer (aka reference type). I'm sure there are other types/objects which are both immutable and a pointer as well and that this extends ...
2
votes
5answers
463 views
A string is immutable, so why are they not all constants?
The string type is immutable.
We can use the const keyword with strings in high level language like .NET. My understanding of 'const' means constant (it remains the same, we can't change the value).
...
4
votes
3answers
206 views
How Immutable Sets are Manipulated
When working with an immutable set or map, like the ones found in many functional programming languages, operations that would otherwise modify the container generate a new container instead.
I know ...
22
votes
4answers
667 views
Do not declare interfaces for immutable objects
Do not declare interfaces for immutable objects
[EDIT] Where the objects in question represent Data Transfer Objects (DTOs) or Plain Old Data (PODs)
Is that a reasonable guideline?
Up to now, I've ...
2
votes
2answers
367 views
How to increase the efficiency of an Immutable Queue in java?
I have been developing an Immutable queue in java, but the version I have developed is supposedly slow and I have been suggested to create a faster version of the same and I have no idea as to how to ...
3
votes
3answers
357 views
Are immutable/stateless singletons bad?
Lately there have been some kind of revolution against singletons, but is there something wrong with them if they are stateless?
I know the overuse talk and all... this applies to everything not just ...
2
votes
4answers
216 views
Immutable Method in Java
In Java, there is the final keyword in lieu of the const keyword in C and C++.
In the latter languages there are mutable and immutable methods such as stated in the answer by Johannes Schaub - litb ...
15
votes
3answers
789 views
Does immutability entirely eliminate the need for locks in multi-processor programming?
Part 1
Clearly Immutability minimizes the need for locks in multi-processor programming, but does it eliminate that need, or are there instances where immutability alone is not enough? It seems to ...
2
votes
3answers
201 views
Internal Mutation of Persistent Data Structures
To clarify, when I mean use the terms persistent and immutable on a data structure, I mean that:
The state of the data structure remains unchanged for its lifetime. It always holds the same data, ...
3
votes
3answers
364 views
Is there any functional difference between immutable value types and immutable reference types?
Value types are types which do not have an identity. When one variable is modified, other instances are not.
Using Javascript syntax as an example, here is how a value type works.
var foo = { a: 42 ...
75
votes
18answers
11k views
If immutable objects are good, why do people keep creating mutable objects?
If immutable objects¹ are good, simple and offer benefits in concurrent programming why do programmers keep creating mutable objects²?
I have four years of experience in Java programming and as I see ...
3
votes
5answers
996 views
Difference between immutable and const
I've often seen the terms immutable and const used interchangeably. However, from my (little) experience, the two differ a lot in the 'contract' they make in code:
Immutable makes the contract that ...
6
votes
6answers
269 views
How does one decide if a data object type should be designed to be immutable?
I love the immutable "pattern" because of its strengths, and in the past I have found it beneficial to design systems with immutable data types (some, most or even all). Often when I do so, I find ...
2
votes
1answer
56 views
Is there any scenario where it's useful to keep mutable properties cached in domain objects for anything else than informational purposes?
Usually in a domain model, you'll have objects, and those objects will have properties that are mutable and properties that are immutable - for instance, a instance id/name will be immutable, while ...
2
votes
2answers
416 views
What's wrong with mutability and can it be desirable? [duplicate]
Possible Duplicate:
At what point do immutable classes become a burden?
This is something I never understood. When learning C++, for instance, I had lots of headaches with const issues, as ...
2
votes
4answers
209 views
Bulk immutability, equals/hashcode in Java
I have a series of classes that represent entities. As I'm trying to follow functional principles, they're methodless and their properties aren't meant to be changed once set.
Implementing equals ...
4
votes
2answers
313 views
Immutable structures and deep composition hierarchy
I'm developing a GUI application, heavily working with graphics - you can think about it as a vector editor, for the sake of the example. It is very tempting to make all data structures immutable - so ...
15
votes
4answers
265 views
Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?
Coming from a OOP background (Java), I'm learning Scala on my own. While I can readily see the advantages of using immutable objects individually, I'm having a hard time seeing how one can design a ...
7
votes
6answers
780 views
Favoring Immutability in Database Design
One of the items in Joshua Bloch's Effective Java is the notion that classes should allow mutation of instances as little as possible, and preferably not at all.
Oftentimes, the data of an object is ...
12
votes
7answers
666 views
Getting My Head Around Immutability
I'm new to object-oriented programming, and one concept that has been taking me a while to grasp is immutability. I think the light bulb went off last night but I want to verify:
When I come across ...
2
votes
2answers
400 views
What are the consequences of immutable classes with references to mutable classes?
I've recently begun adopting the best practice of designing my classes to be immutable per Effective Java [Bloch2008]. I have a series of interrelated questions about degrees of mutability and their ...
27
votes
2answers
872 views
What did Alan Kay mean by “assignment” in The Early History of Smalltalk?
I have been reading The Early History of Smalltalk and there are a few mentions of "assignment" which make me question my understanding of its meaning:
Though OOP came from many motivations, two ...
45
votes
4answers
1k views
Why were Java collections implemented with “optional methods” in the interface?
During my first implementation extending the Java collection framework, I was quite surprised to see that the collection interface contains methods declared as optional. The implementer is expected ...
11
votes
4answers
702 views
Functional Programming — Immutability
I am trying to understand dealing with immutable data in FP (specifically in F#, but other FP’s are ok as well) and break the old habit of state-full thinking (OOP style).
A part of the selected ...
5
votes
7answers
1k views
At what point do immutable classes become a burden?
When designing classes to hold your data model I've read it can be useful to create immutable objects but at what point does the burden of constructor parameter lists and deep copies become too much ...
12
votes
9answers
1k views
Do immutable objects and DDD go together?
Consider a system that uses DDD (as well: any system that uses an ORM). The point of any system realistically, in nearly every use case, will be to manipulate those domain objects. Otherwise there's ...