-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[py] Encapsulated Geo Location co-ordinates using getters/setters
#16079
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
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is required and feels a bit overkill for just validating the coordinates.
If you think of any specific case this would be required, let me know.
@navin772 The co-ordinates gets validated only while creating an instance. But one can change the attributes even after creating instance.. e.g.
So it's Safe and standard practice to have it inside a private attribute and provide access to the user via Getter and Setter interface. Definitely it's not a good practice to have all those attributes validated in constructor. By having separate set of |
|
This seems like a valid argument, what do you think @cgoldberg? |
If we care about enforcing validation of coordinates after the class is instantiated, this PR is good. I don't have a strong preference, but would be fine merging this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove the capitalization in all error messages when referring to an attribute name:
i.e. change:
"Longitude must be between -180.0 and 180.0"
to
"longitude must be between -180.0 and 180.0"
26127f7
to
2f2b83d
Compare
@cgoldberg done! Removed capitalisation of all attributes in error messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
User description
🔗 Related Issues
💥 What does this PR do?
Encapsulated Geo Location co-ordinates using
getters/setters
🔧 Implementation Notes
Rather than having to validate the instance attributes, in this case Geo Location Co-ordinates inside constructor, It's a good idea and a standard practice to encapsulate all geo-location co-ordinates inside
getters/setters
, validate through setter methods. It is very clear from eachsetter
method as to what is the attribute that we are setting and what are upper and lower limits to that attribute.💡 Additional Considerations
🔄 Types of changes
PR Type
Other
Description
Refactored GeolocationCoordinates class to use property decorators
Moved validation logic from constructor to setter methods
Improved encapsulation with private attributes and getters/setters
Diagram Walkthrough
File Walkthrough
emulation.py
Property-based validation for GeolocationCoordinates
py/selenium/webdriver/common/bidi/emulation.py
__init__
method