Skip to content
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

Make parsing and formatting utility method naming more accurate and consistent #925

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

PaulusParssinen
Copy link
Contributor

I have been going back and forth for long time when would be best time to try introduce these changes, so here goes.

This PR makes major naming changes in the "low-level" utility classes: NumUtils and RespRead/WriteUtils. The naming changes are largely mechanical:

  1. Adding Try-prefix to all parsing/formatting methods that return bool indicating whether reading/writing was successful or not.
    i. This matches the .NET API design convention I believe all .NET developers are/should be familiar with. I'm talking about the distinction between int.Parse and int.TryParse. It makes it clear to the developer they need to think about the case where the method can fail "silently" if the output is ignored, if the caller has not considered the assumptions of the method before calling Try method. Generally these Try methods are also the more performant ones that they don't usually throw, and as such incur any exception handling costs.
  2. .NET primitive numeric naming in method names, i.e. (U)Long to (U)Int64. This one is very much preference thing imo, but I saw Read64Int as one method name in the class which made go ahead with this naming change proposal. (This is the concention in BCL)
  3. PR also attempts to improve the xmldoc situation in NumUtils.

Method naming is largely very subjective and hard, but I think these changes are warranted as I believe they improve readability and reduce the mental overhead when working with the parsing/formatting parts of the code-base. I also think that more accurate method naming conventions especially improve code-review process.

I'm very happy and prefer to wait with this PR to minimize any all the conflicts this will have with older PRs still in progress.

…I patterns

* Also makes them more consistent with RespRead/WriteUtils naming
* Revamp xmldoc comments.
* Includes some adjustments in consumption of these methods, no behavioral changes.
…ead/WriteUtils.

* This makes it the assumptions of the method much more visible to callers.
* NumUtils.TryReadDouble/Int64 has no (sane) situatioin it would throw on here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant