-
Notifications
You must be signed in to change notification settings - Fork 278
Reduce complexity of CSVParser.createHeaders() #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hi @sigee, Thanks for the PR. After reviewing the proposed change, I'm not convinced it simplifies the current implementation. The method name Overall, this change appears to increase the cognitive complexity instead of reducing it. It feels more like refactoring for refactoring's sake rather than a meaningful improvement to readability or maintainability. |
Hi @ppkarwasz , Thank you for taking the time to review my PR. I'd like to clarify my approach and reasoning.
I understand your concerns about the method's dual responsibility (returning a value while mutating a parameter). |
I agree with @ppkarwasz, spreading this code around does not help understand or maintain it IMO. |
Hi @sigee,
Metrics like SonarSource's can help highlight areas of higher complexity. However, I think it's more important to assess the resulting code from a human perspective: Does it become easier to understand and maintain? Personally, I found the refactored version a bit harder to follow and would likely need more time to understand it.
I don’t see the nesting as the primary challenge in understanding the method. The more significant cognitive load comes from unpacking the semantic steps of the process—what each block is doing and why. Here’s an approach I believe could make the method clearer:
Let me know what you think—I’m happy to help iterate on this if you agree with some of these ideas. |
Hi @ppkarwasz , I initially wanted to consolidate the dual header data structures - the I also explored your second suggestion, but the extraction isn't feasible due to the numerous dependencies involved - the resulting validate method would need around 6 parameters, making it unwieldy. The first suggestion might be viable, though there's already a getHeaderNames method that serves a different purpose. Perhaps something like |
Instead of spinning our wheels on this "how many angels can dance on the head of a pin" PR which I think is a -1, I offer you all https://issues.apache.org/jira/browse/CSV-257 and |
Uh oh!
There was an error while loading. Please reload this page.