Objects and Values – A conceptual model

Eventually!

I created a blog a long time ago but I never took the time to publish anything on it and I was getting frustrated because I have been ruminating some ideas for years and I wanted to share them with others. So, the time has come!

My first post will be on a subject that has been haunting me for a very long time: “objects and values”. I wrote a short note about it in 1993 and then put the subject to sleep. I went back to it in 2002 and started to write it in book form but I gave up and let it rest. In 2005, I rewrote it as an article but never completed it and again, I let it rest.

I still did not have time to complete this article and it will take me some time to do so because this is a vast subject with lots of ramifications. But I’ve decided to post the first part that I wrote 5 years ago, hoping it will give me the energy to write the rest. As you will see, the examples are outdated but I already had to change them twice and I don’t feel like editing them one more time.

The problem

Programmers use the words “value” and “object” all the time, and they don’t really take the time to define these words. And if they were to define them precisely, I am not sure that they would all agree on what an “object” is and what a “value” is.

Everybody will probably agree on the fact that a window and a button are objects rather than values. But what about an integer, a string? Are they objects too, or are they simple values that don’t deserve the same status as objects? This is the main question that I will try to answer.

The Object Oriented community has a natural tendency to consider that “everything is an object”. For a SmallTalk programmer, a window is an object, a block of code is an object, a string is an object, an integer is an object, etc.

But a FORTRAN programmer is likely to view things differently: he cares primarily about numerical “values” and not as much about “objects”. So, he may have a hard time accepting that an integer or a real number is an “object”, or he may not see any benefit in treating numbers as objects. He is more likely to see them as being values.

So maybe there is no firm answer to a question like “Is an integer an object or a value?”. Maybe the SmallTalk programmer is right into thinking that an integer is an object because this fits his general framework, and maybe the FORTRAN programmer is right too, in thinking that an integer is a value. Or maybe an integer is both an object and a value, and they are just seeing two sides of the same thing.

Or maybe there is something deeper, and there are some fundamental reasons to consider that an integer is a value rather than an object, or to take the opposite stand. And maybe there is simple way to define what an object is and what a value is. This is the conclusion that I have reached and that I will try to explain here.

Semantics and Implementation

Programming issues can usually be attacked from two angles: the semantic angle, in which one focuses on the concepts and their meaning independently from implementations, and the implementation angle, in which one focuses on the implementation and the meaning is somewhat inferred from the implementation.

Here, my line of thought will be driven by the semantics. The distinction that I will be making between objects and values will be a semantic one, and I will deliberately stay away from implementation issues and even from “programming” most of the time.

So, you may be surprised because I will be talking about “Venus” and “Jacques Chirac” at least as much as about pointers and bits. This is because my goal is to give a definition of objects and values that is universal and not related to the specifics of any programming paradigm. Actually, as you will see, this definition has nothing to do with programs and computers.

My intent is to complete this with other posts in which I will deal more directly with the implications of this on programming (and in other areas). So, what follows is just a starting point.

Frege

When we try to come up with definitions for such basic concepts as “object” and “value”, we find ourselves tackling some very abstract issues, almost philosophical in nature, and we are not always equipped for this.

So, we need some “conceptual tools” and a bit of terminology to investigate this fundamental level. The best tools that I found come from Gottlob Frege, a German mathematician, logician and philosopher from the beginning of the 20th century.

Frege investigated fundamental aspects of modern logic and mathematics and tackled important questions like “What is a number? What is a function? What is a concept?”. As I was trying to answer questions of a similar nature (What is an object? What is a value?), I found a great source of inspiration in Frege’s writings.

Frege often uses a “linguistic” angle to attack these difficult questions. His rather abstract discussions are often illustrated by simple sentences like “the earth has two poles” or “Venus is the morning star”. I found this approach very interesting because it steps out of the domain, and gives more power to the argument. Frege’s question is: “What is a number?”, it is not “What is a number for a mathematician?”

Similarly, the questions that I am trying to answer are “What is an object? What is a value?”, they are not “What in an object/value for a programmer?”. This is because I believe that we should try to solve the general question first, and then “apply” our findings to the limited domain of programming rather than do the opposite.

This is part of a general belief that progress in computer science and especially in the design of computer languages will come from a better understanding of our own conceptual structures. We need languages that match our mental organization, rather than artificial languages that are at odds with our mental structures and that force us into a difficult and imperfect translation.

So, I find it very useful to “step out” of the domain first, and try to answer the question at a general level. I think that this will also help the reader because he will not be biased by his own programming background.

Sense and Denotation

Amongst the “conceptual tools” that Frege introduced in his mathematical and logical investigations, there is one that I found really enlightening and that really helped me formalize my thoughts about objects and values: the distinction between “sense and denotation”. So, before going into the heart of the subject, I will quickly introduce this part of his theory:

Frege considers that expressions (names, propositions) have two sides: a sense and a denotation:

  • The “sense” accounts for the “meaning” or “cognitive significance” of the expression itself.
  • The “denotation” is the actual object or value “denoted” by the expression.

This is rather abstract but it gets much clearer with a few examples. Let us start with some simple arithmetic expressions:

  • SQRT(4)
  • 3 – 1
  • 2

These expressions have different “senses”. The first one could be defined as “the positive number whose square is 4”, the second one as “the number that we obtain when we subtract 1 from 3”, and the third one simply as “number 2”. So, if we were to define these expressions (at this level, defining is a bit like paraphrasing), we would give them different definitions. These definitions correspond to the “senses” of the expressions, and it is obvious that these three expressions have different “senses”.

On the other hand, these three expressions “denote” the same number: 2. They have the same “denotation”.

Frege’s approach is not restricted to arithmetic’s. If we take expressions like:

  • The morning star
  • The second planet of the solar system
  • Venus

These expressions have different senses because they resonate differently in our cognitive system and they are not always interchangeable. For example, if we take the following sentence:

John did not know that Venus was the second planet of the solar system because he did not study astronomy well enough.

And we replace “the second planet of the solar system” by “Venus”, we get:

John did not know that Venus was Venus because he did not study astronomy well enough.

We obtain nonsense. This simple substitution exercise shows that these expressions are not always interchangeable; they have a slightly different “sense”.

On the other hand, these three expressions have the same “denotation”. All three denote the Venus planet, a real object somewhere in the solar system.

Note: of course, “Venus” could also “denote” a goddess or a statue, but this is not relevant here because we will assume that the expressions are interpreted within a “context”. In the example above, the context is “astronomy” and, in this context, “Venus” has an unambiguous denotation.

Now, what happens if we apply Frege’s distinction to whole sentences, for example to assertions about arithmetic’s or about the outside world? Take the following:

  • SQRT(4) = 3 – 1
  • The second planet of the solar system is Venus

These two expressions have obviously very different “senses”: the first one expresses an arithmetic truth while the second one states something about the solar system. But what are their “denotations”?

The answer is quite simple: these sentences have the same denotation and this denotation is simply the “true” value. In Frege’s theory, assertions (about numbers, about objects) are expressions that have Boolean values as denotation. They may have very different “senses” but their denotations are either “true” or “false”.

One of Frege’s important findings was that an expression cannot be “reduced” to its denotation. The sense is very important, as demonstrated by the substitution exercise and also by the fact that unrelated assertions (one about numbers, one about planets) may have the same denotation.

I will not dwell much longer on Frege, because I will only need the distinction between the “expression” and its “denotation” in what follows. If you want to know more, you will find a good bio with a complete list of references on http://plato.stanford.edu/entries/frege.

Variables and Constants

Before exploring objects and values, I would like to make a short detour through variables and constants. We have two more “what is” questions to answer: What is a variable expression? What is a constant expression?

Let us consider the following expressions:

  • The French president.
  • Jacques Chirac

These two expressions have the same denotation: a man called Jacques Chirac. But there is a fundamental difference between them: the denotation of the first one changes every 5 years, when a new president is elected, while the denotation of the second one will never change (Jacques Chirac will always be the same person – of course, we have to consider context to rule out homonyms).

I will say that an expression is “variable” when it denotes different things at different times, and that it is “constant” when it always denotes the same thing. This is rather obvious and does not need much further explanation. I will just give a few additional examples.

First, some variable expressions:

  • The French president
  • The temperature in my room
  • Today
  • The number of hair on my head

And some constant ones:

  • Jacques Chirac
  • 21°C
  • 5 days after January 25th, 2005
  • 3 * 4 * 10000

Proper nouns like Venus or Jacques Chirac are usually constant expressions; they always denote the same object or person. Literals like 2, 5 or 38 are also constants; they are more or less the proper nouns that we give to numbers.

Objects and Values

Now, we can answer our main questions: What is an object? What is a value?

I propose the following definitions:

  • An object is a mutable denotation.
  • A value is an immutable denotation.

Let us analyze some of the examples that we used earlier in the light of these definitions.

First, we notice that these definitions apply to “denotations” rather than to the expressions themselves. So, when we apply these definitions to Venus for example, it does not matter whether we call it “Venus” or “the second planet of the solar system” because we are interested in the denotation, i.e. the planet itself, the real thing that circle around the sun. If we decide that Venus is an object, then the second planet of the solar system will also be an object (and will be the same object).

And actually, Venus is an object, because it is mutable: its position in space changes continuously, its temperature changes as its moves around its elliptical orbit, and, if we consider long time scales, Venus was very different in the early days of the solar system than it is today. So, there is no doubt that Venus is “mutable”. Venus is an object.

Similarly, with the definition given above, there is no doubt that Jacques Chirac is an object rather than a value. He gets older every minute, he changes position, he loses hair, etc.

Now, what about numbers? Are they mutable or immutable? If a number like 2 was mutable and if it could mute completely and become identical to 3, then, as 2 is also the denotation of SQRT(4), SQRT(4) would mute as well and would start to denote an odd number. The consequences of such a mutation would be disastrous and all arithmetic rules would fall apart!

Now, what if 2 were to mute partially rather than completely and if only some of its properties would change over time? For example, 2 could become odd but keep its other properties or it could stop being prime, or it could become a perfect square. Our imagination can go rather far here, but if we start to analyze the consequences of these mutations, it becomes quickly obvious that the coherence of our arithmetic system will break as soon as we allow one of these mutations.

So, we can conclude that numbers are immutable. And, with the definitions that I gave above, numbers are values rather than objects.

At this point, it is important to stress the difference between mutable and variable, and the distinction that we made between an expression and its denotation. Let us consider the following expression:

The number of employees in the company.

And let us assume that the company had 26 employees yesterday and just hired a new one. Then, the number of employees in the company went from 26 to 27 and it seems like we have found a counter example: a number that mutes.

This is because we made a confusion between the expression and its denotations. Yesterday, the denotation of the expression was 26 and today, its denotation is 27. But 26 did not mute into 27. Instead, the expression ceased to denote 26 and started to denote 27, a different number. So, the phenomenon that we observe here is a variable expression which denotes different numbers at different times. The numbers themselves are immutable.

This investigation into the true nature of numbers is not really new. Frege had already analyzed this and he had reached the same conclusion, i.e., that numbers are immutable. He did not relate this to categories like values and objects because his focus was on the nature of functions and variables, but his analysis is very clear:

The expression “the number that expresses the length of this stick in millimeters”, without any indication of time, does not designate any number. If we add a temporal indication, we will designate a number, 1000 for example; but it will then be invariable. Another temporal indication yields another expression, which eventually designates another number, 1001 for example. We can say: “half an hour ago, the number that expresses the length of this stick in millimeters was a perfect cube, the number that expresses the length of this stick in millimeters now is not a perfect cube”, the sentence does not have the same subject. 1000 did not, in some sort, inflate to 1001, but has been replaced by 1001. Or else, could it be that 1000 is the same thing as 1001 under different clothing? When something varies, different properties and different states affect the same object successively. If it were not the same, there would be no subject from which we could say that it varies. A stick lengthens under the effect of heat; during heating, it remains the same. If on the contrary, we had taken it away and replaced by another, longer stick, we could not say that it lengthened. A man gets older, but if we could not recognize in him the same man, there would be nothing from which we could state the age. Let us apply this to numbers. What remains identical when a number varies? Nothing. Then, the number does not vary; there is nothing about which we can state a variation. A cubic number never becomes a prime number; an irrational number never becomes a rational number.
(my own translation here — my Frege books  are in French)

This extract of Frege’s “What is a function?” article demonstrates very well the difference that we make between objects and values. A stick or a man are “objects”, they “mute” because some of their properties change with time but they are not “replaced” as a whole. The expressions that designate numbers may vary and may denote different numbers at different times but the numbers themselves are immutable. Numbers are values.

Simple values

Numbers are not the only values that we know of. There are many other things that we can classify as values.

First, physical quantities that we can measure and express with units, for example 1.5 Kg, 23°C, 23µm, etc. are values. This is rather obvious because we would run into the same kind of logical nightmare as we did when we considered mutable numbers if we accepted that these quantities could mute.

Dates and timestamps are values too. Here also, it is important to distinguish expressions from their denotations. Let us consider the following expression:

The deadline for my project

If my project runs late and I cannot reach the original deadline, let us say February 15th, 2005, I will negotiate with the marketing department, and maybe they will accept a new deadline, for example, February 18th, 2005. So, the deadline of my project can change. But does this mean that the date “February 15th” can mute and become “February 18th”? No, because if this were true, then everything that could be said about February 15th, for example that the weather was rainy on that day or that it was a Tuesday, would suddenly apply to February 18th. This is clearly wrong and we have to accept a different interpretation: “the deadline for my project” is a variable expression that takes different denotations. The individual denotations, i.e., the dates, are immutable.

Boolean values are values too: true and false are immutable. If they were not, and if true could mute and become false, then everything that is true would become false and our whole logical system would fall apart. Here also, the distinction between expression and denotation is crucial to avoid confusions. For example, if we consider:

The weather is sunny today.

This expression is false today but will probably be true some other day. This does not mean that false will mute into true, it just means that the expression is variable and takes different denotations on different days.

Representations

Before going much further into our exploration of values and objects, I would like to introduce a new concept: representations. The definition that I will give at this point is rather tautological but it will be helpful:

A representation of an object or a value is an object that represents the object or the value.

This is somewhat circular because I am using the verb “represent” to define the noun “representation”, but despite this flaw, this definition is still useful. First, it says that a representation is an object. Then it says that a representation “represents” and is thus different from the thing that it represents.

All this is relatively obvious and can be illustrated easily:

  • 2, two and 2 are three representations of the number 2.
  • and are two representations of Gottlob Frege.

The representations are objects because they are mutable. For example, I can shrink them, colorize them, etc. And, if the mutations are too severe, for example if I tear the images apart, they may even cease to represent what they represent now.

Bits and Bytes

The distinction that we just made between the thing and its representations will be very useful when we will start to relate this general discussion to computers and programming. It will avoid some serious confusion.

For example, it is very important to make the difference between a value and its representation. The bit pattern 00000010 is only a representation of the number 2, and the fact that this representation can be altered and that a memory location that contained 00000010 can be modified to contain 00000011 does not say anything about 2 as a number, it just says that a given representation of number 2 has been modified, and that it ceases to represent 2 and starts to represent 3 instead. So, when a programmer says that he is “incrementing an integer”, we should not conclude that integers are mutable, because what he is really saying is that he is incrementing an integer variable, and that variable is an object made of bits somewhere in the memory of the computer. At some point in time this sequence of bits represents a certain integer, and at a later time it represents a different integer; but the integers themselves did not change.

Along the same lines, a Java programmer may have some difficulties in accepting that dates are immutable because when he deals with dates, he manipulates them as objects that he can modify like any other object. But this does not say anything about the true nature of dates; it just says that the designers of Java chose to represent dates as mutable objects. And, as I will discuss later, it may also indicate that their design choice is poor and that it would have been preferable to represent dates as immutable values.

So, we need to be careful here. When we are investigating whether something should be classified as a mutable object or an immutable value, we should not be misled by common language like “incrementing an integer”, or by specific representations like the representation that the designers of Java have chosen for dates, we have to analyze the nature of the denotations, not the nature of their representations.

Characters and Strings

Now, we can continue our exploration of values and objects. How should we classify characters and strings? Are they objects or values?

Again, it is important to distinguish characters and strings from their representation. A, A and A are three representations of the character A and we have to make the difference between the character A and the glyphs that represent it.

The true nature of characters is a bit more difficult to apprehend than the true nature of numbers because characters are human creation that did not always exist, while numbers seem to exist independently of us. What is character A? There is no unique glyph that corresponds to A but the various glyphs have a common shape. There is no unique sound either for A but rather a “family” of sounds (car, cable). So, the best way to define character A is probably to say that it is a symbol, and that the various glyphs and sounds are just different representations of this common symbol.

If we accept this definition of characters as being symbols, we have to accept that characters are immutable, very much like numbers. If character A were to mute, what could it become? If it were to mute completely and become another character, B for example, then every A that has been printed in every book would become a glyph for B, and we would have the same logical catastrophe as we had when we imagined that 2 would become 3. And it is difficult to imagine that A would only mute partially and that A, for example, would become a consonant, or would not be a letter any more. All these properties seem to be intrinsic to A, and if A were to mute like this, it seems like our only option would be to consider that A has become another character, and we would end up with two characters: the original A and the mutant A. But the original A would remain and the characters A in all the books would continue to represent the original A rather than the mutant. So, we would have created a new character and the original character would still exist unmodified.

Strings are sequences of characters. For example “flower” and “prime number” are two strings. Like characters, strings may have different representations: flower, flower, flower, etc. The representations can mute but the string itself is immutable. If “flower” were to mute into “prime number”, then flower shops would start selling prime numbers! And even if “flower” were to mute only partially and become, for example, “floxer”, we would have to adjust our knowledge and our pronunciation of English. To keep our sanity, we have to accept that “flower” and “floxer” are two different strings and that the first one will not mute and become the second one.

Expressions

This leads us naturally to our “expression” examples:

  • The French president
  • SQRT(4)
  • The number of employees in the company.

What are these expressions? Are they objects or values?

It is obvious that the first expression above denotes an object and that the other two denote values. But here, we are not concerned by what these expressions denote but by the expressions themselves, by what they are.

These expressions are actually strings that denote objects or values. So, as strings, they are values and they are immutable. If “the French president” were to mutate into “the Queen of England” everything that has been written about French presidents would suddenly apply to Queens of England. We would be very confused!

Here, again, it is important to stress that we are talking about the expressions themselves, not about what they denote, nor about the nature of the denotation. An expression like “the French president” denotes different persons at different times. So it is variable but still immutable.

This last point may seem a bit hard to swallow and needs a bit more explanation. How can something variable be immutable? One way to clarify this is to say that “being variable” is a property of expressions. Some expressions are variable, like the first and third ones above. Others are invariable, like the second one above. But they are immutable: the first and third expressions above are variable and will always be variable. The second one will always be invariable. When we are saying that expressions are immutable, we are considering how the expression itself evolves over time and what would happen if the expression where to mute into a different expression, not how its denotation evolves over time.

So, to summarize we can say that expressions are values that denote objects or values. Invariable expressions are values that always denote the same object or value. Variable expressions are values that may denote different objects or values at different times.

At this point, it is interesting to notice the duality between expressions and representations:

  • Expressions are values that denote objects or values.
  • Representations are objects that represent objects or values

Identity and State

So far, we have been rather focused on values and we have classified the following things as values:

  • Numbers
  • Physical quantities
  • Dates and timestamps
  • Boolean values
  • Characters
  • Strings
  • Expressions

We have not paid too much attention to objects but we assumed that the persons and objects that surround us (a person, a planet, a wooden stick) are objects, because they are obviously mutable.

Being mutable means that some of the properties of these objects can change with time, but it does not mean that everything can change. If everything were to change, then there would not be any reason to consider that we are dealing with the same object. The excerpt from Frege that we quoted earlier explains this very clearly:

When something varies, different properties and different states affect the same object successively. If it were not the same, there would be no subject from which we could say that it varies. A stick lengthens under the effect of heat; during heating, it remains the same. If on the contrary, we had taken it away and replaced by another, longer stick, we could not say that it lengthened.

So, although objects are mutable, there is something about them that is immutable, and that we rely upon to decide whether we deal with the same object, or with two different objects. This immutable part is the identity of the object, and the mutable part is its state. During the lifetime of an object, its identity remains the same but its state changes.

It is a bit difficult to say precisely what the identity of an object is made of. In the case of a person, the administrative identity is not always sufficient because we have to consider the case of a person who “changes identity”. The birth record would probably be more reliable.

In the case of wooden stick, there is no administrative record and we have to rely on our perception: intuitively, we perceive the stick as being one object and we symbolically give it an identity, but this identity is weaker than the identity of a person. What happens if we break the stick in two? If we just cut a small piece out of a long stick, we will probably consider that the stick keeps its identity and that the small chop is a separate object with another identity. But if the stick is broken in the middle, then we will probably consider that the stick does not exist any more, and that we now have two sticks, with new identities. So, we cannot really say precisely what makes up an identity; the identity is more a symbolic thing that allows us to identify the object.

But for a given object, the identity is immutable, and, given our definition of objects and values, it sound logical to conclude that:

the value of an object is its identity.

The state of an object is defined by the set of values that we obtain when we measure properties of the object. For example, a wooden stick has a length, a temperature, a color. We can measure these properties and we obtain values. The values themselves are immutable but the measurement process may yield different values at different times. So, there is no contradiction between the fact that the object is mutable and the fact that values are immutable. The properties of the object are variable, they may denote different values at different times but the individual values are immutable.

Sets

In the previous sections, we have tried to classify individual things (numbers, strings, persons, wooden sticks) as mutable objects or immutable values. But what about sets? Is a set, for example a set of persons or a set of numbers, an object or a value?

Let us consider the following expression:

The employees of the company

And let us assume that the company had 26 employees yesterday and that John joined today. What does the expression “the employees of the company” denote? Does it denote some kind of “bag” object that contained 26 elements yesterday and into which we have dropped John today. Or did it denote a set of 26 employees yesterday and does it denote a different set of 27 employees today?

If we take the OO programmer’s view, there is a good chance that we will adopt the “bag” viewpoint. A programmer is likely to implement a company object as having an “employees” collection, and when John joins the company, he will be added to the collection. The collection is an object and the programmer will not usually create a new collection every time an employee joins or leaves the company.

On the other hand, if we take the mathematician’s view, then the set of 26 employees from yesterday and the set of 27 employees of today are two different sets. When a mathematician adds an element to a set, he obtains a different set and the original set continues to exist (in the mathematician’s mind). It is not modified by the operation.

So, if we take the programmer’s view, sets are mutable objects. But if we take the mathematician’s view, they look more like immutable values. Who’s right?

To answer this, it is useful to go back to the classical distinction between the “intentional” and “extensional” characterizations of sets.

  • The intentional characterization of a set is a predicate that is true for the elements that belong to the set and false otherwise. In our example the predicate would be “is an employee of the company”.
  • The extensional characterization of a set is the enumeration of the members of the set. In our example, it would be an enumeration of names like “Jack Smith, Mary Brown, etc.”.

Mathematicians deal with immutable worlds. For example, number theory deals with the properties of integers and the set of all integers does not change with time. It will be the same tomorrow as it is today. And, when a mathematician considers a predicate about numbers (for example “is prime”), the set of numbers that satisfies the predicate does not change.

So, for a mathematician, the intentional and the extensional characterizations correspond to “frozen” sets that do not evolve in time.

But in the real world, the set of objects that satisfy a given predicate, for example the set of employees that belong to the company, changes with time. When we see the set under the intentional angle, we have a tendency to see it as one thing because the intention (the predicate) remains the same. But when we see it under the extensional angle, we see a different extension every day.

One way to conciliate these two views is to go back to the distinction between sense and denotation:

  • The intentional characterization (the predicate “is an employee of the company”) corresponds to the “sense” of the expression.
  • The extensional characterizations (the enumerations of all employees) correspond to the different denotations of the expression.

In this approach, there is only one sense, which is given by the predicate, but the different denotations correspond to the different extensions that the set takes over time.

So, what we have here is a variable expression that denotes different sets at different times.  The expression is variable but its denotations, the sets, are immutable. If we take this view, we conclude that sets are values.

Symbolic Values and Real Objects

We started this investigation with a simple characterization of objects and values: “objects are mutable, values are immutable”, and we have now identified some objects (persons, planets, wooden sticks) and some values (numbers, strings, Booleans, sets).

If we look at these two lists, we are struck by the fact that objects are things that belong to the real world while values are rather intangible, symbolic constructions that seem to exist only in our minds. This should be no surprise because everything that “exists” and is made of real matter is mutable. Immutable things can only exist in our minds, nothing is truly immutable in the real world.

But we should not conclude too quickly that all objects are real and all values are symbolic and that all this discussion was just a futile exercise to distinguish real objects from symbolic values. The latter is true: values are symbolic and are creations of our minds, but the former is false: all objects are not real. There are objects that don’t exist in the world but that we have to consider as being objects rather than values. For example, fictional characters are objects: they have an identity and they go through different states, just like real objects. They are not frozen, immutable values.

Summary of the Conceptual Model

To conclude this first article, let me quickly summarize the conceptual model that we have explored:

  • Expressions have a sense and a denotation.
  • The sense of an expression accounts for its “cognitive significance”
  • The denotation of an expression is the thing that the expression denotes.
  • Two expressions may have different senses but the same denotation.
  • A variable expression is an expression that takes different denotations over time.
  • A constant expression is an expression that always has the same denotation.
  • An object is a mutable denotation.
  • A value is an immutable denotation.
  • Objects have an identity which is immutable.
  • Objects have a mutable state.
  • Numbers and physical quantities are values.
  • Dates and timestamps are values.
  • Booleans are values.
  • Characters and strings are values.
  • Sets are values.
  • A representation is an object that represents an object or a value.
  • An expression is a value that denotes an object or a value.
  • The value of an object is its identity.
  • Values are symbolic and don’t exist in the real world.
  • Objects are usually real, but not always.

Links

Objects vs. Values, by Jean-Hugues Robert

Advertisements
This entry was posted in Programming - Conceptual. Bookmark the permalink.

9 Responses to Objects and Values – A conceptual model

  1. Coudeyras says:

    You should take a look at Domain Driven Design, which seems to be close to your concerns (but applied in business software). The distinction between Value Objects (immutable, no identity, ie defined by his attributes) and Entities (mutable, defined by its identity).
    A short introduction to Entity and Value Object :
    http://www.domaindrivendesign.org/node/109
    http://www.domaindrivendesign.org/node/135

  2. Carlos Serrano-Morales says:

    Well, Bruno…

    Let me congratulate you on joining the Blogosphere – it was time you came contribute your knowledge and wisdom! I am glad you are doing it.

    It’s interesting that you should choose this subject to get started. I had imagine you would start by either this or something related to languages and semantics. I still remember the very stimulating and rich debates we had a number of years ago. A lot of what you explained and described back those years stuck with me, and helped me through the rest of my programming projects. One of those was precisely an early view on the conceptual model you describe here, focusing on the complicated issues with values, objects and identity.

    Recently, I have been dealing with the issues with covariance and contra-variance in the typing systems for .NET. A bunch of issues connected to what you describe here, although the whole thing seems to still be evolving.

    One other issue I am dealing with has to do with relations. The more I work with objects, the more I think a model in which object relations are externalized and not part of the objects makes sense. I do not know whether you’ve spent time thinking about it, but in essence it seems to be that relations really need to be treated as top level entities, parallel to objects and values – the key reason being that they have semantics and lifecycles that are different from that of objects. I am actually trying to approach a problem we have in the past solved (not that well) using standard object approaches using an approach inspired from graph databases, in which relations become key.
    It would be great to get your input on all that.

    In any case, great to see you here!
    Carlos.

    • Hi Carlos and thanks for the kind words.

      I’m going to write about relations at some point (about functions and threads too). It is difficult to give a short answer but I agree with your conclusion that we are wrong when we treat relations as parts of objects, especially N-M relations. These relations need to be managed externally to the objects and “queried” rather than “stored”. The objects may “cache” them internally but the truth should not be in these cached collections, it should be in something that is external to the objects.

      More on this later.

  3. Oleg Sych says:

    Hi Bruno,

    Welcome to blogging and thanks for making me think about some of the things we take for granted in the .NET Framework. I enjoyed it and look forward to more mind benders.

    Oleg

  4. I’m glad to see that some of my own “obsessions” are shared. See http://virteal.com/ObjectVersusValue

    Thanks for the “intentional characterization” vs “extensional characterizations” clarification. In my article I use the “in extenso” expression, but apparently in the wrong way.

    Jean Hugues

    • I looked at your article. Looks like we really have the same “obsessions” here. And it is actually funny to see how close our views are. Made me feel good!

      I was going to write a follow-up article in which I was going to talk about equality, parameter passing, multi-threading, etc. But it looks like you got it all figured out. So I’m not sure that I’ll bother writing this because I would probably be stating the obvious.

      I’m completely in line with your analysis of parameter passing. In a clean language, there should only be “passing by value”. When you pass an object, you actually pass the object’s value, which is its identity. Passing the object itself just does not make sense. The only parameter passing variants that make sense are “in”, “out” and “in-out”, but they always apply to a value.

      I’m adding a link to your blog.

      Bruno

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s