[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Jonathan Rees on OO



Personally I find OO quite useful. I can see how it's not really needed in language like Lisp and Scheme but I also find it useful in those languages. Especially if the type of OO includes multi method dispatch ala Clos, Dylan and SmallScript.

I find that OO in this manner (and yes, I'm picking a subset of your menu for my purposes) helps to create libraries of components that are easily extendable without breaking open that libraries implementation (and needing source for example).

For example, an OO text editor might have a method 'display-line' for displaying lines of text on a window (example taken and modified from a text editor framework written in Dylan called Deuce):

  define generic display-line(line :: <line>, mode :: <mode>, window :: <window>);

This method displays a line of 'something' on a window using a particular display mode (major modes, etc, ala Emacs).

The standard editor might come with a method for text lines on a basic window using a simple text mode:

  define method display-line(line :: <text-line>, mode :: <text-mode>, window :: <window>)
    // display it
  end;

Without breaking open the source of the editor I can create additional libraries that add functionality easily for different modes, lines and windows:

  define method display-line(line :: <graphic-line>, mode :: <graphic-mode>, window) ... end;
  define method display-line(line :: <text-line>, mode :: <text-mode>, window :: <console-window>) 
     ... 
  end;

Now I know you all know this and I know there are ways of doing this without OO, but I find the OO way easy and extensible. So much so I prefer languages with this OO style. What's bad about that?

Note, SmallScript examples of the above below just for comparison and to attempt to make this less of a 'pro-dylan' type of post:

  Method behavior: Line [
  mode: <Mode> aMode window: <Window> aWindow
    /* do something */
  ]

  Method behavior: TextLine [
  mode: <TextMode> aMode window: <Window> aWindow
    /* do something */
  ]

  Method behavior: GraphicLine [
  mode: <GraphicMode> aMode window: <Window> aWindow
    /* do something */
  ]

  Method behavior: TextLine [
  mode: <TextMode> aMode window: <ConsoleWindow> aWindow
    /* do something */
  ]

Chris.