me.at.coding
me.at.coding

Reputation: 17724

Looking for a pattern / keep a property of several objects in sync

[Sorry for the title, I really didn't find a good one, if anyone has an idea, please edit, thanks!]

Hello,

I'm looking for a pattern / best practice for the following situation (just an example).

Imagine an editor for rectangles (just e.g. adding, resizing, removing rectangles). All rectangles shall have the same color, however this general color shall be changeable. The rectangle color shall be set using the editor class, something like

editor.RectangleColor = Red

The color shall however not be changeable directly on the rectangles, because this would probably allow an individual color for every rectangle.

What's the best way to realize this? Thanks in advance for any hint!

Upvotes: 0

Views: 105

Answers (1)

this. __curious_geek
this. __curious_geek

Reputation: 43217

I think Observer pattern should help in this situation.

Upvotes: 1

Related Questions