Esri / arcgis-maps-sdk-swift-samples

SwiftUI samples demonstrating various capabilities of ArcGIS Maps SDK for Swift
https://developers.arcgis.com/swift
Apache License 2.0
31 stars 10 forks source link

Get rid of unneeded static properties #112

Open yo1995 opened 1 year ago

yo1995 commented 1 year ago

In 200.0.0-beta, because we used the StateObject-for-map pattern, many view properties are created as type property, or gets their default value from a static method. This is not a memory efficient approach as many static properties will stay in the memory longer than desired.

Instead, we can move the static methods into the traditional initialization process, and make the properties instance properties instead of type properties. Most often seen with graphics and graphics overlays.

See "Using Computed Variable" in the contribution guideline for more details.

yo1995 commented 1 year ago

https://github.com/Esri/arcgis-maps-sdk-swift-samples/pull/182#discussion_r1205881553

I would argue that static methods are sometimes essential to declutter the initializer. Compared to static properties, they shouldn't be a huge problem as the memory footprint can be pretty small, just a pointer to a method vs the static properties object size.

While we are examining all static and class keywords for type methods/properties, most of the time we only need to fix the properties in question.

Criteria

yo1995 commented 4 months ago

https://github.com/Esri/arcgis-maps-sdk-swift-samples/pull/436#discussion_r1664876029