Properties and Shared Properties??

I am just curious when should we use Shared Properties instead of the usual Properties??

Shared Properties act as Global properties for the class themselves and not a specific instance.
“Static” is another keyword some languages use for this.

For an example
I might have a shared property called “HowManyOfTheseHaveIMade” as integer

Then in the constructor I could call

HowManyOfTheseHaveIMade = HowManyOfTheseHaveIMade + 1

I could then anywhere in code call:


To determine how many i’ve made. I wouldn’t need to instantiate an instance of the class to get this property.

as pointed out in some Feedback case and in the blog post, the access to shared properties in app class is magnitudes faster than normal properties due to the time needed to find the app object.

so the shared properties in the class is to expose to the method outside the class.

If you had a class who’s super is canvas, add a shared property called backColor. If you set the backColor on any of your instances they all assume the property.

i.e. set the backColor to red, all instances of the canvas turn red. If this was not a shared property only the instance on which you changed the property would turn red.

i see…