Well, keyword arguments can be used well in ruby, though clearly, in the code you've been dealing with they haven't.
Some guidelines.
Use .merge for default values, not ternary operators.
Keep it minimal. Rails does a good job of using keywords for stuff that's optional, and positional arguments for stuff that isn't. For instance
Here, the arguments you need, the link title and href are non-optional positional args. HTML attributes OTOH are option hash args..
It sounds like in the code you've inherited, though I can't be sure, there are fairly complicated hashes being passed around all kinds of places. These should probably be objects, not hashes, in the first place. I'll admit though, I can't be certain from my limited vantage point.
I think the hashes instead of objects paradigm contributed to my frustration.
I ended up turning parts of the hashes into objects and parts into parameters.
You and your sibling post provide some decent guidelines and approaches to default arguments. My experience with Ruby has lead me to believe that it's an awesome language, but a language which I'd be very careful about with whom I collaborated.
Comments
Well, keyword arguments can be used well in ruby, though clearly, in the code you've been dealing with they haven't.
Some guidelines. Use .merge for default values, not ternary operators. Keep it minimal. Rails does a good job of using keywords for stuff that's optional, and positional arguments for stuff that isn't. For instance
Here, the arguments you need, the link title and href are non-optional positional args. HTML attributes OTOH are option hash args..It sounds like in the code you've inherited, though I can't be sure, there are fairly complicated hashes being passed around all kinds of places. These should probably be objects, not hashes, in the first place. I'll admit though, I can't be certain from my limited vantage point.
I think the hashes instead of objects paradigm contributed to my frustration.
I ended up turning parts of the hashes into objects and parts into parameters.
You and your sibling post provide some decent guidelines and approaches to default arguments. My experience with Ruby has lead me to believe that it's an awesome language, but a language which I'd be very careful about with whom I collaborated.