views:

25

answers:

1

I've been reading about using flexible properties instead of strongly typed fixed properties by using Dictionary or something similar to store them in. An obvious advantage for using flexible properties is that you can change what properties an object has at runtime.

What are some interesting use cases for this kind of behavior?

Some related literature:

+1  A: 

One benefit is something along the lines of what Apple calls Key-Value coding in Cocoa. It allows you to centralise the usual operations that you might want to do to a property; e.g., getting, setting, etc. By doing so, you get to do things like use the observer pattern to notify other objects of changes without having to code the boilerplate stuff for each property in each object that you might want to observe.

RibaldEddie