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

Callback should be the last argument #53

Closed
diversario opened this issue Jan 19, 2015 · 3 comments
Closed

Callback should be the last argument #53

diversario opened this issue Jan 19, 2015 · 3 comments

Comments

@diversario
Copy link

Having something other than a callback as the last function argument goes against node conventions and it's inconsistent with other methods in the module that have callback as the last argument.

@alevy
Copy link
Member

alevy commented Jan 20, 2015

I agree, but for now, it's done for backwards compatability, since some parameters were added after the fact. See #50 for a short discussion on the matter. I plan on making this change eventually, and am more than happy to merge pull requests so long as they either maintain backwards compatability or have a reasonable upgrade path (even if either is hacky for now).

@rdegges
Copy link

rdegges commented Apr 3, 2015

I think the long-term solution to this is to release a major release (1.0.0 type stuff), which breaks backwards compatibility. Semantic Versioning typically works this way: major releases which increase the first number are expected to introduce backwards-compatibility breaking behaviors.

@dterei
Copy link
Collaborator

dterei commented Apr 29, 2016

Amit, I think there are four options here:

  1. Add variants of functions, basic:

    var set = function(key, value, callback)
    var set_ = function(key, value, flags, expires, version)
    
  2. Use a dictionary for all arguments:

    var set = function(args, callback)
    set({key: 'hello', value: 'world'}, function(...
    
  3. Use a dictionary for extended arguments:

    var set = function(key, value, options, callback)
    set('hello', 'world', {}, function(...
    
  4. Similar to (1), but have the advance variant take a dictionary to make the code easier to read:

    var set = function(key, value, callback)
    var set_ = function(key, value, args, callback)
    set_('hello', 'world', {expires: 100, flags: 1337, version: 37}, function(...
    

In terms of what the ideal function interfaces should look like (ignoring backwards compatibility for now).

Once we choose a style, I think we just make a break changing with a version between or two with deprecations for migration time.

dterei added a commit that referenced this issue May 14, 2016
We now declare methods generally as:

        function(key, value, options, callback)

Rather than adding each argument (generally unused) as trailing
arguments after callback. Callback is _always_ the last argument now.

To handle backwards compatability, we check the type of `options` and if
it is a function, we treat arguments as corresponding to the old
interface but issue a depreceated warning.

This fixes issue #53 and #50, making CAS also easier to support going
forward.
dterei added a commit that referenced this issue Nov 16, 2016
We now declare methods generally as:

        function(key, value, options, callback)

Rather than adding each argument (generally unused) as trailing
arguments after callback. Callback is _always_ the last argument now.

To handle backwards compatability, we check the type of `options` and if
it is a function, we treat arguments as corresponding to the old
interface but issue a depreceated warning.

This fixes issue #53 and #50, making CAS also easier to support going
forward.
dterei added a commit that referenced this issue Nov 16, 2016
We now declare methods generally as:

        function(key, value, options, callback)

Rather than adding each argument (generally unused) as trailing
arguments after callback. Callback is _always_ the last argument now.

To handle backwards compatability, we check the type of `options` and if
it is a function, we treat arguments as corresponding to the old
interface but issue a depreceated warning.

This fixes issue #53 and #50, making CAS also easier to support going
forward.
@dterei dterei closed this as completed Nov 17, 2016
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

4 participants