Skip to content

API design & conventions #58

@DLehenbauer

Description

@DLehenbauer

Researching various API nits to see if I can find a compelling majority. (Feel free to comment/add).

Conventions

Intervals expressed as start/count?

Currently I use start/count because it's unambiguous wrt. if the 'end' is inclusive/exclusive.

insertRows(startRow: number, numRows: number);
  • Excel does the same.
  • Math.js uses inclusive start / exclusive end.
  • Most modern JavaScript APIs use start / end (exclusive).

Points, intervals, etc. are open-coded as numbers (as opposed to arrays, objects, etc.)

This was done out of fear of hidden array/object allocations, but never verified.

read(rowStart: number, colStart: number, rowCount: number, colCount: number);

Vector, Matrix, etc. are distinct types.

Related to the above, if we were to pass coordinates/sizes as arrays, we could generalize vectors, matrices, etc. to n-dimensional arrays.

Naming

'col' as an abbreviation for column?

insertCol(col: number, numCols: number);

'numRows' as an abbreviation for 'number of rows'?

  • Excel uses 'rowCount', which is probably easier to discover in Intellisense.
  • Math.js has a single '.size' property that returns a [number, number].
  • ndarray has a single '.shape' property that returns a 'number[]'.

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