> 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.
More later.
Sent from my iPhone
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
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;
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 + 5c. 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 drawb. window.drawc. window.draw()
d. window–>draw()
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?
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.times { puts "3 is an object!" }
MvhRune2011/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...-RistoMathmaticians 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.
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()
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? ;-)
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?
The argument against numbers being objects has to do with cardinality
2011/10/19 James O. Coplien <jcop...@gmail.com>The argument against numbers being objects has to do with cardinalityI don't find that to be a convincing argument for numbers not being objects (not trying to prove that they are either).
Rune := James is as weird as 1 := 2.
In Java, I write that like this:
you.takeOut(garbage);
Not so hard, eh?
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...
>
> 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.
> 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.
> 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"?
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.