nathanaschbacher / nodiak

Nodiak is a Node.js client for the Riak Distributed Database
MIT License
43 stars 16 forks source link

Arguments object overuse #23

Closed phated closed 9 years ago

phated commented 10 years ago

The arguments object is overused in the codebase. Many usages of this object cause engine slowdown and it also makes the codebase very unreadable.

nathanaschbacher commented 10 years ago

I'll take a look at the performance concerns. Should be pretty easy to isolate the actual impact. With respect to readability of the codebase, the point was to facilitate a particular end-user API experience that is more pleasant to deal with.

The head of some functions being internally initially messy to sort out is primarily a concern for me as the client implementor and maintainer. I wanted a pleasurable means of interacting with Riak as an end user to trump some internal implementation annoyance baggage.

I could address the potential performance impact by just using named function arguments and then checking against their type/existence at the head of each function to be able to publish the same external API, but that honestly doesn't seem any cleaner than mucking about with the arguments object. :-/

nathanaschbacher commented 9 years ago

So, the microbenchmarking shows some difference in performance, though it's not significant. It barely registers as noise over the lifetime of the function call.

However, I think I've come up with a way to implement the same external API in a way that's less horrible to maintain on the interior of the client, so when I do the refactor for the Riak 2.0 client I'll sort this out then.