2016-03-30 19:53 GMT+02:00 Marko Rauhamaa : > I like OOP, only I don't like GOOPS. Its classes and generic functions > seem so idiomatically out of place, unschemish, if you will. > > This is how OOP ought to be done: > > l#OO-Closure> > > The problem with closures is, among others, that they are non-serializable (I think that Termite solves some of those issues gracefully) I have created a tiny Guile module ("simpleton") that generalizes the > principle. In particular, > > * You don't need classes for OOP. You only need objects. > > JavaScript made a similar assumption, which -- I believe -- turned out cumbersome, because I sometimes have to pretend that it has classes despite that it doesn't. > * Do tie methods to objects. Don't pretend methods are external to > objects. * Don't expose the internal state of objects. Only interact with the > object through methods. I think it is a good rule, but it's better if you can do without state. I believe that methods *are* external to objects. Linguistically, you don't "button.press()"; you "press(button)". I also think that tying methods to objects is one of the problems of OOP, because the designer of an object has to know in advance which actions on an object are conceivable. Perhaps certain devices, like tape recorders, are modelled well within OOP -- you have a well-defined interface (like the play, rewind, fast-forward button) and a hidden internal state. But I'm afraid that this metaphor doesn't scale well.