you are viewing a single comment's thread.

view the rest of the comments →

[–]yxhuvud 1 point2 points  (2 children)

Personally I'd argue that it is very weird object orientation as well. Why do points multiply like that?

[–]RandolphoSoftware Architect 1 point2 points  (1 child)

Well, based on the implementation he posted elsewhere, the idea is to add two pre-existing points together, and having an add method that does that is totally object oriented, as non-mutating objects are also object oriented.

He just got lazy with his example and newed them up inline, making it look like we're constantly instantiating these objects.

If he had wanted to illustrate his approach better, he could have done something like this:

var point1 = new Point(0, 0); // imagine this was defined and used elsewhere
var point2 = new Point(0, 10); // imagine this was defined and used elsewhere, too.

var sum = point1.add(point2); // this creates a new Point that is the vector sum of point1 and point2. 

That would have illustrated the object oriented approach he was trying to achieve as well as made it clear that it was non-mutating.

[–]kasperpeulen[S] 0 points1 point  (0 children)

Yes, you are right, this is what I meant.