Skip to content

Confusing type names: Graphic and Graphic2D #22

@apblack

Description

@apblack

The type Graphic2D is a specialization of type Graphic that adds methods for interrogating the size of, and resizing, the object. This is not apparent from the names.

Worse, there is no type that represents a Graphic with a size. Class

drawable2DAt (location': Point)
      size (dimension': Point)
      on (canvas': DrawingCanvas)

claimed that it generated a Graphic2D, when it actually generates a

Graphic & interface {
    width -> Number
    height -> Number
    size -> Point
}

When the compiler started generating a check for the return types, it failed. Commit f0e8b71 corrects the code.

However, errors like this are easy to make with such non-mnemonic names. I suggest either that all Graphics have a size, or, if this is infeasible, that we use three types Graphic, SizableGraphic, and ResizableGraphic. Add the 2D suffix to all of them if you like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions