-
Notifications
You must be signed in to change notification settings - Fork 86
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
Using constants for field positions #51
Comments
We may require the I wouldn't mind going for the second one, but for segments with a lot of fields, the number of constants would grow and make the class quite unwieldy, which are already quite large as it is. |
The problem I see it that changing the position argument may not have the desired effect in all cases. For example, if the position argument in
To me this means the user is lead to believe all positions can be changed, yet if that happens other parts of the library will break. If certain implementations use different positions for different fields, it should be set in a single place so all references to this position then use the correct number. Anyway, I will prepare a PR which makes use of the constants, but leave the argument in the getters and setters. I hope you like it and can consider it for a merge. |
Please go ahead. While I agree in MSH changing positions of some fields does not make sense, other segments may be slightly flexible. The library gives the user flexibility while keeping sane defaults. So if the users want to override something, they can, but only by being explicit about it. |
Would you be open to receiving a PR for adding constants to the segments (and perhaps drop the $position argument completely)? Hard-coding the same value in setter and getters seems a bit odd and by using constants you have additional benefits in your IDE and documentation.
For simple segments, one could even completely bypass the getter and setters without the risk of using the wrong position:
I propose to change the segments like this:
or like this
The text was updated successfully, but these errors were encountered: