Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not a fan of the API #4

Open
rreusser opened this issue May 14, 2015 · 7 comments
Open

Not a fan of the API #4

rreusser opened this issue May 14, 2015 · 7 comments

Comments

@rreusser
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member Author

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
Copy link
Member

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

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

@rreusser
Copy link
Member Author

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
Copy link

kgryte commented May 15, 2015

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
Copy link
Member Author

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. 😄 I may still just separate this into components at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants