polymorphism

21 views
Skip to first unread message

Ant Kutschera

unread,
Oct 6, 2011, 2:52:49 AM10/6/11
to dci-evolution
I want to talk about polymorphism and DCI.

Whats the difference between listing 1 & listing 2:

----- 1 -----
Collections.sort(list, comparator)


----- 2 -----
list.sort(comparator)

The first isn't object oriented, it's procedural, almost more service
oriented. What does that mean? It means the code in listing 1:

a) does not match the mental model*, because in the real world there
are no god-objects like "Collections",
b) has poor coherence, because the data is not near the behaviour,
c) cannot apply polymorphism to specialise the behaviour.

So in OO, listing 2 is king. And it's great, until we add more and
more and more behaviour to the list class and we lose the context in
which individual methods are called. Reading the code becomes very
difficult and you have no idea which methods are called from where.
You end up working in the debugger just to work out what's going on at
runtime as lots of objects interact with each other.

The basic idea behind DCI which claims to solve these problems of OO,
is that you move all the behaviour out, into specific roles.
Polymorphism becomes illegal, although inheritance (from abstract
classes in order to inherit common behaviour) is still allowed, in
order to reduce duplicate code, if you choose to.

So back to the code listings. In DCI, we notice how that in the
context of sorting, the list is playing a special role, namely that of
a "sortable list". A SortableList "is a" List, so the role passes the
"is a" test. The behaviour required to sort the list is moved away
from the List class and into a role definition.

Now, listing 2 is supposed to be good, because it allows subclasses to
override the sort method and provide specific behaviour. How can we
do that in DCI?

Well, one argument would be that within a specific context, the type
of sorting which is required is known, and so you just provide the
specific sorting behaviour which you want in that context.

But take a different example, namely one where you have products as
domain objects. When printing a product on a receipt, you want the
product to be able to provide the text which should appear on the
receipt, so you can put that text into a print job object which can be
passed to the printer API to do the physical printing. Now imagine
subclassing the standard product class, so that you have a class which
models a specific product which includes say a discount, or a coffee
voucher; something extra which should be printed with the text on the
receipt. Lets call that type of object ProductWithVoucher.

In plain OO, you would create a subclass of Product, and just call the
"getPrintText" method which would provide the correct text, depending
on the specific type, via polymorphism. How would you do this in DCI,
where the role is printable product, and contains the method
"getPrintText"?

Well, we can create a role named PrintableProduct, and then create a
subclass of it, called say the PrintableProductWithVoucher role. Both
have their own implementations of the "getPrintText" method. Let's
ignore the fact for now that this is currently cited as illegal in
DCI, because it depends on polymorphism. So far, the solution looks
good.

But the problem comes when we go to bind domain objects of type
Product (or its subclass) to the role they will play in the context of
printing a receipt. We are forced to choose a specific role in order
to get the correct behaviour. That is unsatisfactory, because it
leads to "if" statements. Consider listings 3 and 4 (written in Java
centric pseudo-code) which are two alternative ways that I can think
of getting the correct text into the print job object.

I find both very unsatisfactory. They check on exact types using the
"instanceof" keyword, which if used typically means you are not
building an OO solution.

What would you do?

PS. Reading up on how extension methods will be done in Java, it will
be posisble for subclasses to bind differernt implementations,
effectively using polymorphism. Doesn't DCI need to figure this out
too?


----- 3 Using a specialised role -----

public PrintReceiptContext(List<Product> products){
this.products = products;

//bind roles now
for(Product p : products){
if(p instanceof Product){
bind(p, PrintableProduct.class);
}else if(p instanceof ProductWithVoucher){
bind(p, PrintableProductWithVoucher.class);
}else {
throw new RuntimeException("unknown type - code change
required");
}
}
}

role PrintableProduct {
String getPrintText(){
return self.productCode.substring(0,10).rightPad(12) + " " +
self.price.format();
}
}

role PrintableProductWithVoucher extends PrintableProduct {
String getPrintText(){
return super.getPrintText() + "\r\n" + self.voucherCode;
}
}

void execute(){
PrintJob pj = new PrintJob();
for(Product p : products){
pj.addLine(p.getPrintText());
}
... send pj to printer
}

----- 4 Using one role which knows about all types of product -----

public PrintReceiptContext(List<Product> products){
this.products = products;

//bind roles now
for(Product p : products){
bind(p, PrintableProduct.class);
}
}

role PrintableProduct {
String getPrintText(){
if(self instanceof Product){
return getPlainText();
}else if(self instanceof ProductWithVoucher){
return getPlainText() + "\r\n" + self.voucherCode;
}else {
throw new RuntimeException("unknown type - code change
required");
}
}

private String getPlainText(){
return self.productCode.substring(0,10).rightPad(12) + " " +
self.price.format();
}
}

void execute(){
PrintJob pj = new PrintJob();
for(Product p : products){
pj.addLine(p.getPrintText());
}
... send pj to printer
}


* but that depends on how you make your mental model...

James O. Coplien

unread,
Oct 6, 2011, 10:21:44 AM10/6/11
to dci-ev...@googlegroups.com

On Oct 6, 2011, at 8:52 , Ant Kutschera wrote:

> I want to talk about polymorphism and DCI.
>
> Whats the difference between listing 1 & listing 2:
>
> ----- 1 -----
> Collections.sort(list, comparator)
>
>
> ----- 2 -----
> list.sort(comparator)


Syntactic saccharin.

ant.ku...@gmail.com

unread,
Oct 6, 2011, 12:53:57 PM10/6/11
to dci-ev...@googlegroups.com
Sorry for asking hard questions you can't answer.

James O. Coplien

unread,
Oct 6, 2011, 1:03:28 PM10/6/11
to dci-ev...@googlegroups.com, dci-ev...@googlegroups.com
Grrrrr ... :-)

More later.

Sent from my iPhone

Wenig, Stefan

unread,
Oct 6, 2011, 1:31:52 PM10/6/11
to dci-ev...@googlegroups.com
> From: James O. Coplien
> Sent: Thursday, October 06, 2011 4:22 PM

I got a tough rebuke when I suggested context.sort(), although that seems to solve all other technical problems that were discussed here before and one that wasn't...

I think it was because the missing syntactic sugar creates a mental mismatch. (Which it does without doubt)

Stefan

ant.ku...@gmail.com

unread,
Oct 6, 2011, 2:41:24 PM10/6/11
to dci-ev...@googlegroups.com
The interesting part of my posting was nearer the bottom.  The first two listings can almost be ignored!




----- Reply message -----
From: "Wenig, Stefan" <stefan...@rubicon.eu>
To: "dci-ev...@googlegroups.com" <dci-ev...@googlegroups.com>
Subject: polymorphism

James O. Coplien

unread,
Oct 18, 2011, 11:43:28 AM10/18/11
to dci-ev...@googlegroups.com
O.K., class. Here is a quiz.

1. Which is more object-oriented? Rank them.

a. myvector at: 1 put: "value"
b. myvector[1] = "value"
c. myvector[1] := "value"
d. cset(a "value")

2. Which is more object-oriented? Rank them.

a. + \ (1 2 3 4 5)
b. 1 + 2 + 3 + 4 + 5
c. sum(1, sum(2, sum(3, sum(4, 5))))
d. 1 + (2 + (3 + (4 + 5)))

3. Which is more object-oriented? Rank them.

a. window draw
b. window.draw
c. window.draw()
c. window–>draw()

4. Is this object-oriented?

 Current :- First;
	While Current ne None do begin
	    Inspect Current
   		When A do Show    ! Show of A;
   		When B do Show    ! Show of B;
   		When C do Show    ! Show of C;
    		Otherwise OutText("Not a (sub)class of A");
  	    OutImage;
  	    Current :- Current.Link
	End While;

Benjamin Scherrey

unread,
Oct 18, 2011, 12:02:04 PM10/18/11
to dci-ev...@googlegroups.com
Based on my understanding of OO and not my preferences here goes:

1:a,d,c,b
2:a,c,d,b
3:a,d,c,b (nearly random guesses here)
4.no, not the way i think of it.

On Tue, Oct 18, 2011 at 10:43 PM, James O. Coplien <jcop...@gmail.com> wrote:
O.K., class. Here is a quiz.

1. Which is more object-oriented? Rank them.

a. myvector at: 1 put: "value"
b. myvector[1] = "value"
c. myvector[1] := "value"
d. cset(a "value")

2. Which is more object-oriented? Rank them.

a. + \ (1 2 3 4 5)
b. 1 + 2 + 3 + 4 + 5
c. sum(1, sum(2, sum(3, sum(4, 5))))
d. 1 + (2 + (3 + (4 + 5)))

3. Which is more object-oriented? Rank them.

a. window draw
b. window.draw
c. window.draw()
d. window–>draw()

Wenig, Stefan

unread,
Oct 18, 2011, 12:23:22 PM10/18/11
to dci-ev...@googlegroups.com

My take on 1 – 3 is they all might be object oriented, but there’s no telling from the syntax alone (with the exception of 1a, which obviously is OO). If myvector[1] = value gets translated to a message sent to myvector, telling it to set item #1 to value, it’s just as OO as 1a. We might guess that this is most likely a feature of a class-oriented language though.

 

No. 4 looks like http://c2.com/cgi/wiki?SwitchStatementsSmell to me, so no. Can’t quite read it though, is it Simula?

Ant Kutschera

unread,
Oct 18, 2011, 3:09:21 PM10/18/11
to dci-evolution
On Oct 18, 5:43 pm, James O. Coplien <jcopl...@gmail.com> wrote:
> 1. Which is more object-oriented? Rank them.
>
>         a. myvector at: 1 put: "value"
>         b. myvector[1] = "value"
>         c. myvector[1] := "value"
>         d. cset(a "value")

OO starts with analysis and design. You choose your entities based on
things that exist in the real world. Normally, they are nouns. I'd
be interested in seeing a picture of a vector...

So some techie decided to take advantage of inheritance, polymorphism,
classes, etc. and built a class to represent a vector, which I can
only guess is a little like an array.

Let's say a "vector" was something that really existed in the real
world, perhaps something like a cupboard with shelves. Then what
"behaviour" would it exhibit? Hmm.. "giving" you the item on a
particular shelf? OK, let's say its a robotic cupboard, so it can
give you things...

Then it might have behaviour like "give" which needs to know from
which shelf number to take. And it imight have behaviour like "take",
which takes "something" from you and put's it on the shelf you
specify, or the highest, if not specified. It might even move
everything downwards to fill spaces, after every "give" and "take".

None of those method calls are OO as far as I am concerned, because I
cannot clearly read which behaviour is being used. Well, maybe A is
the closest to my expectations.

> 2. Which is more object-oriented? Rank them.
>
>         a. + \ (1 2 3 4 5)
>         b. 1 + 2 + 3 + 4 + 5
>         c. sum(1, sum(2, sum(3, sum(4, 5))))
>         d. 1 + (2 + (3 + (4 + 5)))

That techie guy who created the "vector" seems to have got carried
away and tried to turn numbers into objects. Show me a "1" please,
and I mean the object, not a picture of it. Numbers are not objects
because they are not nouns. "The farmer fed three sheep". Objects:
farmer, sheep. Behaviour: feeding. At best, "three" is an adjective.

> 3. Which is more object-oriented? Rank them.
>
>         a. window draw
>         b. window.draw
>         c. window.draw()
>         d. window–>draw()

OK, now we are talking! Windows are real things! Oh wait.. As I look
out the window pondering this question, I cannot imagine it drawing
itself... The techies have been at work here too! But so far, this
is the best example of OO. All are equally OO, IMO.

> 4. Is this object-oriented?
>
>          Current :- First;
>         While Current ne None do begin
>             Inspect Current
>                 When A do Show    ! Show of A;
>                 When B do Show    ! Show of B;
>                 When C do Show    ! Show of C;
>                 Otherwise OutText("Not a (sub)class of A");
>             OutImage;
>             Current :- Current.Link
>         End While;
>

If it is, I hope I don't have to maintain it! I don't know what the
"!" operator does for starters. And "OutText" - that is behaviour,
but from which class or object?

Risto Välimäki

unread,
Oct 18, 2011, 3:37:14 PM10/18/11
to dci-ev...@googlegroups.com


2011/10/18 Ant Kutschera <ant.ku...@gmail.com>

Show me a "1" please,
and I mean the object, not a picture of it.  Numbers are not objects
because they are not nouns.  "The farmer fed three sheep".  Objects:
farmer, sheep.  Behaviour: feeding.  At best, "three" is an adjective.

Ruby people disagrees :)

This is valid ruby code:
3.times { puts "3 is an object!" }
3 is an object type of Fixnum. "1" is an object too, type of String...

-Risto 

rune funch

unread,
Oct 18, 2011, 3:43:17 PM10/18/11
to dci-ev...@googlegroups.com


Mvh
Rune
Mathmaticians in general are know to claim that both numbers, vectors and sets are objects in their mental model. They are abstract but none the less real. 

To which is OO I'm with Wenig with out knowing the semantics of each statement it's guess work whether or not something is object oriented and I'm with Ant that OO starts way before the code. 

Risto Välimäki

unread,
Oct 18, 2011, 3:50:33 PM10/18/11
to dci-ev...@googlegroups.com


2011/10/18 rune funch <funchs...@gmail.com>



Mvh
Rune

Den 18/10/2011 kl. 21.37 skrev "Risto Välimäki" <risto.v...@gmail.com>:



2011/10/18 Ant Kutschera <ant.ku...@gmail.com>
Show me a "1" please,
and I mean the object, not a picture of it.  Numbers are not objects
because they are not nouns.  "The farmer fed three sheep".  Objects:
farmer, sheep.  Behaviour: feeding.  At best, "three" is an adjective.

Ruby people disagrees :)

This is valid ruby code:
3.times { puts "3 is an object!" }
3 is an object type of Fixnum. "1" is an object too, type of String...

-Risto 

Mathmaticians in general are know to claim that both numbers, vectors and sets are objects in their mental model. They are abstract but none the less real.

Exactly. I already typed that numbers are abstract real world objects, but took it away before posting.

You can't taste, smell and touch all objects.

-Risto

Wenig, Stefan

unread,
Oct 19, 2011, 6:26:07 AM10/19/11
to dci-ev...@googlegroups.com
Objects are just nouns, right? Being a Java guy, some would argue that even your verbs will eventually turn into objects*), but I think we can at least agree that vectors and numbers are fine nouns, right? ;-)

This is not to say that one should necessarily do DDD or role modeling on integers...

Stefan

*) http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html

> >         d. window->draw()

Ant Kutschera

unread,
Oct 19, 2011, 8:02:50 AM10/19/11
to dci-evolution
On Oct 19, 12:26 pm, "Wenig, Stefan" <stefan.we...@rubicon.eu> wrote:
> Objects are just nouns, right? Being a Java guy, some would argue that even your verbs will eventually turn into objects*), but I think we can at least agree that vectors and numbers are fine nouns, right? ;-)
> *)http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns...


That article is interesting. Although it's author clearly doesn't
understand Java that well. Functions do exist as stand alone things.
If he had ever written an assertion in a JUnit test, he might know
that. When I go on about SOA, I am talking about stand alone verbs
too. The fact that they live in a file with the keyword "class" at
the start has nothing to do with my mental model of such services.
There aren't two instances of say the "AccountingService", one with
blue eyes the other with green eyes. "AccountingService" is not an
object - it is a namespace in which to find operations relating to
accounting. Just like the "Plane" role isn't a class, its a place to
find behaviour related to playing the role of a plane (i.e. flying).

But it is true, many Java programmers get carried away making their
solutions extremely technical, using every possible "pattern" that
exists. Just look at Qi4J - its full of stuff that no reader cares
about.

What I found most interesting in his article was who was taking the
garbage out? Because the use case steps involved "wash *your* hands",
I can only assume he was thinking that it was as person doing the
work. Hence, the subject of the actions is "you", the verb "take out"
and the object "garbage". In Java, I write that like this:

you.takeOut(garbage);

Not so hard, eh?

Of course, that is OO. If you want a first class verb, like the
author wants, try this:

takeOut(you, garbage);

Also not hard, eh? Oh, how can I do that in Java? "static import".

But now I can't remember what this thread was about... Oh yeah,
polymorphism and DCI roles.

So let's say you have two domain model classes like Product and
ProductWithVoucher which is a subclass of Product. And in the context
of printing, you want to add behaviour specific to the type of domain
object. How do you do that, without an ugly "if" statement where you
check the exact type of objects, during role assignment?

In the mean time, I rediscovered dynamic polymorphism. If you
overload methods with specific types of parameters, a type system
capable of dynamic polymorphism selects the correct method at runtime,
based on the actual type of the objects being passed as parameters.

Java can't do it, but C++ can, I believe.

public String getPrintText(Product p){
return p.productCode.substring(0,10).rightPad(12) + " " +
p.price.format();
}

public String getPrintText(ProductWithVoucher p){
return p.productCode.substring(0,10).rightPad(12) + " " +
p.price.format() + "\r\n" + p.voucherCode;
}

Then I can call "getPrintText", using a reference to a Product even
though the actual object is a ProductWithVoucher, and at runtime, the
type system works out if the object is actually a ProductWithVoucher,
in which case it calls the second method.

Those two methods aren't role methods though, because they take the
object as a parameter, rather than operating on "self". So in DCI,
I'd have to write the methods a little different, and have a way to
tell the compiler / runtime type system, which method is to be called
for which role-player type.

E.g.:

role PrintableProduct playedBy Product {

String getPrintText() when Product {
return self.productCode.substring(0,10).rightPad(12) + " " +
self.price.format();
}

String getPrintText() when ProductWithVoucher {
return self.productCode.substring(0,10).rightPad(12) + " " +
self.price.format() + "\r\n" + self.voucherCode;
}
}

See the "playedBy" keyword? That tells me what the role contract is.
Product isn't necessarily a domain class - it could simply be a list
of methods which role players wanting to play this role MUST have.

See the "when" keyword, followed by the type? That signals the
runtime to call the relevant method, depending on the role players
exact type.

It's possible that OT/J already has this kind of mechanism, I don't
know.

There is one thing missing. In OO Java, I have the keyword "abstract"
which tells the compiler, I must override a method when creating a
subclass. It's nice, because it sometimes helps me to realise that I
still have something to implement, when I create a new subclass, say a
year after going live with the first version of my software.

So, let me add a similar keyword to the role, which results in code
like this:

role PrintableProduct playedBy Product explicitly {

String getPrintText() when Product {
return self.productCode.substring(0,10).rightPad(12) + " " +
self.price.format();
}

String getPrintText() when ProductWithVoucher {
return self.productCode.substring(0,10).rightPad(12) + " " +
self.price.format() + "\r\n" + self.voucherCode;
}
}

See the "explicitly" keyword? That means the programmer has to
provide a method for every possible sub-type of Product.

I'm not sure how DCI languages would really compile all this - in my
mind there is still confusion between role-contracts and role-players
in the above code... But I hope you understand my requirements.

James O. Coplien

unread,
Oct 19, 2011, 11:55:30 AM10/19/11
to dci-ev...@googlegroups.com

On Oct 19, 2011, at 12:26 , Wenig, Stefan wrote:

Objects are just nouns, right? Being a Java guy, some would argue that even your verbs will eventually turn into objects*), but I think we can at least agree that vectors and numbers are fine nouns, right? ;-)


The argument against numbers being objects has to do with cardinality, and that had implications for the discussions around the treaty of Orlando. If numbers are objects, they are pretty weird objects. There is only one instance of the literal value "1" in the universe. You don't have two literal "1" objects floating around in a program.

(Of course, this caused some embarrassing problems in FORTRAN and other languages with call-by-reference semantics:

FUNCTION INCR(I)
I = I + 1
RETURN
END

PROGRAM TEST
PRINT 10, 1
   10 FORMAT(1X, I2)
INCR(1)
PRINT 10, 1
STOP
END

actually prints:

  1
  2

Saying that an object is a noun carries very little information. As Stefan said, you can noun any verb (and can verb any noun). We talk about Event objects. An event isn't a thing; it is a point in time. We can create an object to represent some happening at that point in time, and the representation is a noun, but the event itself is not. At best, objects are representations of things that we consider as things, and from a philosophical perspective you have to go beyond a semantic analysis to an epistemological and hermeneutic analysis. At that level, the term "object" is itself an object, and things get much weirder than the analysis here evidences...

James O. Coplien

unread,
Oct 19, 2011, 12:00:39 PM10/19/11
to dci-ev...@googlegroups.com

On Oct 19, 2011, at 2:02 , Ant Kutschera wrote:

Hence, the subject of the actions is "you", the verb "take out"
and the object "garbage".  In Java, I write that like this:

   you.takeOut(garbage);

Not so hard, eh?

O, this is unbelievably hard. "Take out" is not a verb: it is an adverbial phrase. The word "out" an adverb specifying place: A NOUN!

The term "you" is not a noun, either, but a pronoun. It stands for a noun — just like an Event object can stand for an Event, even though an Event is a happening rather than a thing.

In fact, the variable you in your program is just the name of the pronoun, which itself stands in for a noun.

This silly "underline the nouns" approach to OOA is just silly, and defining an object as "a noun" is only marginally helpful for newbies to programming.

Jeremy Pullen

unread,
Oct 19, 2011, 12:47:40 PM10/19/11
to dci-ev...@googlegroups.com
+1

Ant, I was trying to figure out a way to articulate very similar thoughts.  Thanks for getting it out for me.

Rune Funch Søltoft

unread,
Oct 19, 2011, 2:18:00 PM10/19/11
to dci-ev...@googlegroups.com


2011/10/19 James O. Coplien <jcop...@gmail.com>


The argument against numbers being objects has to do with cardinality

I don't find that to be a convincing argument for numbers not being objects (not trying to prove that they are either). There's only one earth in the universe so the cardinality argument would prohibit me to represent that as an object, there's also only ever going to be one of each of us, but we make fine objects as persons in a system. Representing both the earth and any of us of course requires abstraction but that does not change the cardinality of the value represented. Rune := James is as weird as 1 := 2. I don't think that just because there's only ever going to be one of something it doesn't qualify for an object.

"At best, objects are representations of things that we consider as things"

Now that makes a lot more sense to me than simply looking at cardinality. However on my phone I have a key board where each button represents one character each. I could model each key as an object with behaviour or I could model each key as a context and let the character play a role. Now that the character is playing a role, is it then a "thing"?

Best regards
Rune

James O. Coplien

unread,
Oct 19, 2011, 3:39:22 PM10/19/11
to dci-ev...@googlegroups.com

On Oct 19, 2011, at 8:18 , Rune Funch Søltoft wrote:

2011/10/19 James O. Coplien <jcop...@gmail.com>

The argument against numbers being objects has to do with cardinality

I don't find that to be a convincing argument for numbers not being objects (not trying to prove that they are either).


I am not defending the argument, either:  just conveying what I have historically understood to be one of the prime rationales.

James O. Coplien

unread,
Oct 19, 2011, 3:41:37 PM10/19/11
to dci-ev...@googlegroups.com
On Oct 19, 2011, at 8:18 , Rune Funch Søltoft wrote:

Rune := James is as weird as 1 := 2.

On Oct 19, 2011, at 2:02 , Ant Kutschera wrote:

In Java, I write that like this:

   you.takeOut(garbage);

Not so hard, eh?


If you is an object, can I say you := me ?


:-)

James O. Coplien

unread,
Oct 19, 2011, 3:53:39 PM10/19/11
to dci-ev...@googlegroups.com

On Oct 19, 2011, at 6:47 , Jeremy Pullen wrote:

So some techie decided to take advantage of inheritance, polymorphism,
classes, etc. and built a class to represent a vector, which I can
only guess is a little like an array.

Let's say a "vector" was something that really existed in the real
world, perhaps something like a cupboard with shelves.  Then what
"behaviour" would it exhibit?  Hmm.. "giving" you the item on a
particular shelf?  OK, let's say its a robotic cupboard, so it can
give you things...


The problem with these arguments is that they don't have a sound basis either in physics or in psychology. Shelves don't exist in the world as a thing: only as a pattern our mind recognizes when certain atoms come together in a certain formation. Reality is in the mind rather than in the objective world.

DCI is about mental models, and to understand what mental models are about, you need to bring a dose of psychology to the table. That something has form implies existence at the level of human cognition and reason. Form can be formalized using group theory, using groups with a strict invariant and all the other usual properties of groups (closure, presence of an identity and an inverse, etc.) The resulting group is called a symmetry group and is used to describe form in a certain geometry. Rosen talks about form and cognition this way:

Systems that might possess symmetry are not confined to the domain of concrete objects, but may be abstract to the extreme. The transformations involved do not have to be geometric; the imagination is free to roam: space, time, particle-antiparticle, permutation, and on to the abstract. Neither must the invariant aspect be appearance nor physical property, but may be any concrete or abstract aspect of the system under consideration. However, the very least we need for symmetry is the possibility of making a change and some aspect that is immune to this change. (J.Rosen.Symmetryatfoundationsofscience.InIHargittai,editor,InSymmetry
2: Unifying Human Understanding. Pergamon Press, 1989.)

So unless we want to take this into existensual metaphysics (in which most of the arguments in this thread are based) from a practical perspective of human design and problem solving, existence transcends corporeal existence and embodies things like vectors. Most people, when presented with a concept of a vector, conjure up a picture in their head (about 80% of the population). There are some people who think of a vector in formal or abstract terms, usually in terms of linguistic concepts (about 15% of the population). And then there are a few odd cases. But humans are wired intellectually to perceive symmetrically characterized form apart from any corporeal existence. To say that a vector doesn't have form would be like denying that Shakespeare wrote Hamlet. After all, he probably didn't have any actors in the room when he wrote the play. It was just all in his mind.

Ant Kutschera

unread,
Oct 20, 2011, 3:15:10 AM10/20/11
to dci-evolution


On Oct 19, 6:00 pm, "James O. Coplien" <jcopl...@gmail.com> wrote:
> On Oct 19, 2011, at 2:02 , Ant Kutschera wrote:
>
> > Hence, the subject of the actions is "you", the verb "take out"
> > and the object "garbage".  In Java, I write that like this:
>
> >    you.takeOut(garbage);
>
> > Not so hard, eh?
>
> O, this is unbelievably hard. "Take out" is not a verb: it is an adverbial phrase. The word "out" an adverb specifying place: A NOUN!


While you are right, you are also massively over cooking it.

Keep things simple and don't go looking for trouble. It's thinking
like this which causes people to build classes for verbs and use names
like MediatorProxyFactory, whatever that is...

So where were you headed with your quiz and how did it relate to my
thread?

James O. Coplien

unread,
Oct 20, 2011, 5:57:33 AM10/20/11
to dci-ev...@googlegroups.com

On Oct 20, 2011, at 9:15 , Ant Kutschera wrote:

>
> While you are right, you are also massively over cooking it.

We are talking about programming language implementations here. This is not philosophy. As Trygve often says, we are not talking about general human behavior. Digital computers are unbelievably precise and unforgiving, so precision is important.

If we want to be philosophical, then another kind of precision is called for, and I think my rhetoric also fits it.

The current discussion is too vague either for philosophical dialectic or to drive technical discussions about type systems and language implementations. I am not over-cooking it.

James O. Coplien

unread,
Oct 20, 2011, 6:00:04 AM10/20/11
to dci-ev...@googlegroups.com

On Oct 20, 2011, at 9:15 , Ant Kutschera wrote:

> So where were you headed with your quiz and how did it relate to my
> thread?


I'm glad you asked. Those who said that OO is about semantic and not syntax are probably closest to the right answer.

I posted this because some earlier posts headed into mico-managing the syntax of presentation. Remember all those arguments about which syntax was superior? The arguments of those posts align only arbitrarily with what people chose here, and that's my point.

The last example, by the way, is from the primordial object-oriented programming language Simula. Even those who chose to choose usually chose it last. As Jerry Weinberg might say: That's information.

James O. Coplien

unread,
Oct 20, 2011, 6:10:14 AM10/20/11
to dci-ev...@googlegroups.com

On Oct 18, 2011, at 9:09 , Ant Kutschera wrote:

> On Oct 18, 5:43 pm, James O. Coplien <jcopl...@gmail.com> wrote:
>> 1. Which is more object-oriented? Rank them.
>>
>> a. myvector at: 1 put: "value"
>> b. myvector[1] = "value"
>> c. myvector[1] := "value"
>> d. cset(a "value")
>
> OO starts with analysis and design. You choose your entities based on
> things that exist in the real world. Normally, they are nouns. I'd
> be interested in seeing a picture of a vector...


http://en.wikipedia.org/wiki/Vector_(C%2B%2B)

See the section suitably titled "Vector visualization."

Can you rebut this in a way that is not "massively over-cooking it"?

Ant Kutschera

unread,
Oct 23, 2011, 4:11:55 PM10/23/11
to dci-evolution


On Oct 20, 12:00 pm, "James O. Coplien" <jcopl...@gmail.com> wrote:
> I'm glad you asked. Those who said that OO is about semantic and not syntax are probably closest to the right answer.
>
> I posted this because some earlier posts headed into mico-managing the syntax of presentation. Remember all those arguments about which syntax was superior?  The arguments of those posts align only arbitrarily with what people chose here, and that's my point.
>
> The last example, by the way, is from the primordial object-oriented programming language Simula. Even those who chose to choose usually chose it last. As Jerry Weinberg might say: That's information.

So are you saying that the following snippet could be OO?

calculateCost(node);

The syntax doesn't look that way. But in the language used here,
programmers read it as "call the calculateCost method on the node
object".

James O. Coplien

unread,
Oct 24, 2011, 12:09:51 AM10/24/11
to dci-ev...@googlegroups.com, dci-evolution
The real question is: Why would I care? I think we know the answer to that by now.

That aside, as is true in general when reading any literary work, the answer depends on the language in which it is expressed and the associated cultural expectations it invokes.

Reply all
Reply to author
Forward
0 new messages