Posted: Aug 13, 2010 11:56 am
by newolder
VazScep wrote:...
newolder wrote:In my mind, self.trash takes the object in focus to the nearest waste receptacle. For example, the object in focus is a 1mm ball of steel in the hand before me. Self.trash causes magnet-like attraction whilst self.destroy makes the ball vanish. Am I way off?
I'm not sure. What languages are you familiar with? As Calilasseia said, objects are trashed in OOP languages by entities on the outside. Garbage-collecting languages deal with trash automatically, so this "taking out the trash" metaphor is pretty confused.

self.trash doesn't help you anymore than object.trash. "self" can't generally be used. The main point here is that trashing in the example has become a property of the object. Is that a reasonable assumption to make? Is trashing not equally a property of the trash-can? What about the cupboard under the sink? What about the person who carries the bag? Why is only the trash-bag given sole responsibility here, aside from the fact that Java insists on all verbs being owned by nouns? Do we not have a procedure here, something like:

person.acquireFrom(trashBag, sinkCupboard);
person.goTo(garage);
person.placeIn(trashBag, trashCan);

Now where do we put this procedure? Procedures in Javaland belong to nouns, so we need something like:

trashDisposalPlan.doIt(person, sinkCupboard, garbageCan)

Incidentally, "doIt" methods are common in Java. This is called the "Command Pattern", and is a great example of how OOP has been horribly confused by Java and the "Patterns Community" [*]. The Command Pattern is normally just a crude hack to simulate "first-class functions", which are not available in Java (they are now in C#), and which were always supported by Smalltalk and exploited pervasively.

[*] Design patterns have also been horribly confused by the "Patterns Community".

Z80-assembly, Basic, Fortran, Pascal (e.g. “Delphi”), VB6, VB and metalanguages like sql etc.

I'm pretty sure I've coded the likes of

With self do
Begin
{code}
End; {With}

before now. :scratch: