Code Monkey home page Code Monkey logo

Comments (8)

abonas avatar abonas commented on June 27, 2024

while at it, I recommend renaming it to simply 'data' per ruby conventions. (the get/set_X is less popular in ruby)

from hawkular-client-ruby.

jkremser avatar jkremser commented on June 27, 2024

I was looking into it and it is actually using hash. There is a difference between

def get_data(id, starts: nil, ends: nil, bucketDuration: nil, buckets: nil, percentiles: nil, limit: nil, order: nil)

and

def get_data(id, starts = nil, ends = nil, bucketDuration = nil, buckets = nil, percentiles = nil, limit = nil, order = nil)

Both methods takes the id as a first param. The difference here is that the second method can accept optional parameters, but it's an ordered list, so if I wan't to specify, say, buckets, but don't want to specify anything else, I have no way to do that.

The second signature is different, the order doesn't matter, because technically the method accept an id and a hash. I can call the first method as

get_data(42, starts: now - (2 *foo), ends: now - foo)

(https://git.io/vre0e)

or even

additional_params = {
  start: foo,
  end: bar,
  order: baz
}
get_data(42, additional_params)

note: Ruby doesn't allow to call the 2nd method this way get_data(42, now - (2 *foo), now - foo). I.e. w/o explicitly naming the params in the hash.

So i think, we are good here as for the hash and passing the arguments. Correct, me if I am wrong or missing something.

So what about the get_data -> data renaming, does it worth to break the api?

from hawkular-client-ruby.

jkremser avatar jkremser commented on June 27, 2024

Oh, and it's Ruby 2+ feature, but it shouldn't be the issue (https://robots.thoughtbot.com/ruby-2-keyword-arguments)

from hawkular-client-ruby.

pilhuhn avatar pilhuhn commented on June 27, 2024

So I hear you saying @Jiri-Kremser this is no issue and already works? If so, could you add some tests please that use this alternate style to make sure it continues to work in the future?

from hawkular-client-ruby.

jkremser avatar jkremser commented on June 27, 2024

this was the original:

def get_data(id, starts: nil, ends: nil, bucketDuration: nil, buckets: nil)

and this is the new version:

def get_data(id, starts: nil, ends: nil, bucketDuration: nil, buckets: nil, percentiles: nil, limit: nil, order: nil)

(https://github.com/hawkular/hawkular-client-ruby/pull/36/files#diff-a9c2c337e0e2e8129b0179df69635862L119)

This is not a breaking change. I think, it's well tested (https://git.io/vrJIm) but I can add a case for get_data being called with all the possible arguments.

from hawkular-client-ruby.

jkremser avatar jkremser commented on June 27, 2024

#65

from hawkular-client-ruby.

pilhuhn avatar pilhuhn commented on June 27, 2024

@abonas "So what about the get_data -> data renaming, does it worth to break the api?"

from hawkular-client-ruby.

abonas avatar abonas commented on June 27, 2024

@pilhuhn regarding breaking the api - it depends how many users the ruby client has. if only 1 and we know who, and it's one place to rename - I'd go ahead and rename it.
in any case there's also an option to do "alias_method" and document the "new" method name, that won't break a thing.

from hawkular-client-ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.