Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: RE: [platform-swt-dev] org.eclipse.swt.SWT

> I agree with your points if the Point class is to be used
> inside a Drawing Tool.

This is the problem, IMHO. When someone designs a class, there's no way
they can know all the possible places that class is truly useful.

Why should there have to be multiple Point classes? The concept should
be incredibly reusable. If it had been designed

  class Point {
    private int _x, _y;
    public int getX() {return _x;}
    public int getY() {return _y;}
    public void setX(int x) {_x = x;}
    public void setY(int y) {_y = y;}
  }

it could later be modified or subclassed to provide additional services
such as notification, or different implementations such as automatic
origin translation.

As it currently exists, the only way to have a notifying Point, is to
create an entirely new class...
Something that could have been infinitely reusable, isn't...

Bottom line: Three of my "rules of reuse" apply here:

* (rule 1) All data must be private
* (rule 2) Most (if not all) data should be exposed as JavaBean
properties (ie getters/setters)
* (rule 4) The get/set methods should be protected (or better, public),
so subclasses can override and call

(I think I might need to add another rule -- all objects must be created
via factories, so the factory could replace the actual type of object
returned with a subclass under certain circumstances... hmmm...)
-- Scott




Back to the top