scijs / window-function

Collection of window functions
58 stars 6 forks source link

Not a fan of the API #4

Open rreusser opened 9 years ago

rreusser commented 9 years ago

Something feels weird about the way the API is written. I tried to keep it simple and verbose, but I'm worried it backfired and feels weird instead. Open to any suggestions here.

mikolalysenko commented 9 years ago

Maybe instead of hanging all the window functions off module.exports, you could make them individually requirable. For example:

var hann = require('scijs-window-functions/hann')
mikolalysenko commented 9 years ago

Also not sure we need the generate function. You could just use ndarray-fill or whatever you like to initialize an array. It is too much.

rreusser commented 9 years ago

Totally valid. A slash in the name? I wasn't aware that was valid for parts of an npm module. Or do you mean separate repos?

mikolalysenko commented 9 years ago

You can do it in a module. Look at this for an example:

https://github.com/stackgl/gl-mat4

rreusser commented 9 years ago

I like this pattern, but I'm hesitant to use it too much. I think it strikes a good balance between requiring minimal amounts of code and bundling up nearly identical things just a little. Splitting these into repos would be fine too, but it's a little challenging to juggle the feature set of 100+ repos in my head.

Curious to hear your thoughts, @kgryte and @Planeshifter. Do you think this would be a valid approach for, e.g., constants:

// this:
var MAX_INT8 = require( 'compute-const-max-int8' );

// becomes:
var MAX_INT8 = require( 'compute-const/max-int8' );

Browserified code is identical, right?

Not to get hung up on this, but reorganizing repos and APIs over and over is moderately costly, time-wise.

kgryte commented 9 years ago

We have automated the process to a large extent. So I do not find setting up repos to be too much a chore. The main manual bits are setting up coveralls, travis, and other web hooks.

For functions which share code, e.g., a common class, etc., having them organized in the same repo and individually requirable is fine. And yes, browserified code will be the same.

While the browserified code would not be the same, you effectively could have had the same usage when hanging everything on exports just by

var hann = require( 'scijs-window-functions').hann;

My main principle is one module one concern. How people define the scope of that concern is up to them.

I also have the principle 'when in Rome do as the Romans do'. Scijs has a close relationship with stackgl, so I can sympathize with wanting consistency.

rreusser commented 9 years ago

Thanks. Your input is valued. I'm still trying to cement my style conventions, in particular because I just showed up and started picking the low-hanging fruit on someone else's project. :smile: I may still just separate this into components at some point.