[py] Encapsulated Geo Location co-ordinates using getters/setters#16079
[py] Encapsulated Geo Location co-ordinates using getters/setters#16079cgoldberg merged 3 commits intoSeleniumHQ:trunkfrom
getters/setters#16079Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
navin772
left a comment
There was a problem hiding this comment.
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. |
26127f7 to
2f2b83d
Compare
|
@cgoldberg done! Removed capitalisation of all attributes in error messages. |
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 eachsettermethod 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 GeolocationCoordinatespy/selenium/webdriver/common/bidi/emulation.py
__init__method