-
Notifications
You must be signed in to change notification settings - Fork 1.3k
MGLShapeCollection.shapes should be writable #7458
Comments
Making the array mutable would run into the same problem as #7459. But we can still make the property read-write without running into that problem. |
@1ec5 It is very risky and considered as a bad design to provide mutable containers in the interface. Please consider adding following methods instead:
|
Thanks @andrewstay, in that case, we can certainly provide individual getters and setters without making the array mutable. This will likely be the solution to #7459 as well. |
I think we should consider implementing the KVO methods for mutable containers. That way the developer can call the standard |
@1ec5 The solution suggested by you looks like encapsulation violation as it exposes internal logic to the client. |
Would it be? I thought |
To make things cleaner:
When user of your objects access private property with the knowledge that it is a mutable container and can modify it using KVC it is a direct violation of encapsulation and should be avoided as much as possible. |
Sorry for being thick: I was conflating KVC and KVO. In fact, I’m also overthinking things: the collection methods needed for |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
MGLShapeCollection’s
shapes
property should be a read-write mutable array, so that the developer can (for example) append a shape to the collection directly rather than having to create a new MGLShapeCollection to change the shapes within an MGLShapeSource.The implementation would be similar in scope to #6160, although without any C++ wrangling.
/cc @bsudekum
The text was updated successfully, but these errors were encountered: