Define FunctionSignature - #4176
Conversation
dfda9f0 to
6db005f
Compare
6db005f to
bde99ef
Compare
Codecov Report
@@ Coverage Diff @@
## main #4176 +/- ##
============================================
- Coverage 84.26% 84.25% -0.01%
+ Complexity 3245 3238 -7
============================================
Files 468 469 +1
Lines 10178 10199 +21
Branches 1787 1792 +5
============================================
+ Hits 8576 8593 +17
Misses 658 658
- Partials 944 948 +4
Continue to review full report at Codecov.
|
| functions[5] to false, // fun compare(hello: String, world: Int) | ||
| ), | ||
| ) | ||
| } |
There was a problem hiding this comment.
This is a matrix of cases. Given a list of MethodSignatures and a list of function declarations I want to say if it should match or no. And then check all those cases and see that it's correct.
Do you know any better way to write this and no make it a maintainance hell?
There was a problem hiding this comment.
What I can think of is to give each functions element a specify name, such as ToStringNoArg, ToStringOneArg, ToStringTwoArgs, CompareNoArg, CompareOneArg, and CompareTwoArgs.
This does prevent magic numbers being used, but the maintenance cost is still there.
There was a problem hiding this comment.
I had that. The problem is that the readability is a bit worst:
ToStringNoArg to false, // fun toString()
ToStringOneArg to false, // fun toString(hello: String)
ToStringTwoArgs to false, // fun toString(hello: String, world: Int)
CompareNoArg to false, // fun compare()
CompareOneArg to false, // fun compare(hello: String)
CompareTwoArgs to false, // fun compare(hello: String, world: Int)vs
functions[0] to false, // fun toString()
functions[1] to false, // fun toString(hello: String)
functions[2] to false, // fun toString(hello: String, world: Int)
functions[3] to false, // fun compare()
functions[4] to false, // fun compare(hello: String)
functions[5] to false, // fun compare(hello: String, world: Int)The second one keeps the columns aligned so it's a bit easier to read and modify. Usually I don't care about alignment and I would vote against comments that are far too easy to get outdated but in this case I'm not that sure. Do you think the first is better?
There was a problem hiding this comment.
I like the former one. The second has the horizontal alignment but I agree with "Clean code" that it shouldn't matter - Once we have more than 10 items, we do not get columns fully aligned anymore.
Additionally, I don't think the comments become necessary in the former case.
picklebento
left a comment
There was a problem hiding this comment.
I like FunctionSignature. If we want to emphasize its core functionality, we can call it FunctionMatcher.
| functions[5] to false, // fun compare(hello: String, world: Int) | ||
| ), | ||
| ) | ||
| } |
There was a problem hiding this comment.
What I can think of is to give each functions element a specify name, such as ToStringNoArg, ToStringOneArg, ToStringTwoArgs, CompareNoArg, CompareOneArg, and CompareTwoArgs.
This does prevent magic numbers being used, but the maintenance cost is still there.
f71d8a5 to
800d094
Compare
800d094 to
5631bf0
Compare
This class is a helper that I need to implement #4148. I moved it outside that PR becase the code is complex and have entity by itself.
I'm not very happy with all the naming that I'm using so any suggestion there is that regard is more than welcome.