Live data from Hacker News

Chrome Issue 652543: ContextualSearchLayer::SetProperties takes 51 parameters

bugs.chromium.org

1–3 of 3 posts

Re: Chrome Issue 652543: ContextualSearchLayer::SetProperties takes 51 parameters

#2
android::ContextualSearchLayer::SetProperties(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, float, scoped_refptr const&, bool, float, float, int, int, bool, float, float, int, int, bool, float, bool, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, bool, bool, float, bool, bool, float, int, int, int, float, bool, float, float, float, bool, float, float, int, int)

Re: Chrome Issue 652543: ContextualSearchLayer::SetProperties takes 51 parameters

#3
My first reaction to this would be to change it to take as struct, but the ticket comments reveal why this is not a good idea: those are C++ functions called from Java, and Java's translation layer (JNI) does not support structs at all.

It looks like the "recommended" case would be to create a new class, add a setter for each parameter, and pass it. But this is a lot of extra code, and many more function calls, which will slow down the program.

If I were in their shoes, I would keep it as-is, but add an explanation comment. If this patter turns out to be both common and error-prone, I'd consider codegen which emits definition of C++ struct, Java caller and C++ receiver with matching parameter list.