开发者

Receive Events from the Business Objects

开发者 https://www.devze.com 2023-01-02 16:13 出处:网络
How to keep receiving events even with changed references? In a project I have the following relation between BO (Business object) and GUI

How to keep receiving events even with changed references?

In a project I have the following relation between BO (Business object) and GUI alt text http://lh5.ggpht.com/_1TPOP7DzY1E/TA9kkB1tNfI/AAAAAAAADOw/Myf_QBM3hS0/s800/Capture6.gif

By e.g. G could represent a graphic with time lines, C a TimeLine curve, P - points of that curve and T the time that represents each point.

Each GUI object is associated with the BO corresponding object. When T changes GUI P captures the Changed event and changes its location.

So, when G sho开发者_运维技巧uld be modified, it modifies internally its objects and as result T changes, P moves and the GuiG visually changes, everything is OK.

But there is an inconvenient of this architecture... BO should not be recreated, because this will breack the link between BO and GUIO.

In particular, GUI P should always have the same reference of T.

If in a business logic I do by e.g. P1.T = new T(this.T + 10) GUI_P1 will not move anymore, because it wait an event from the reference of former P1.T object, that does not belongs to P1 anymore.

So the solution was to always modify the existing objects, not to recreate it. But here is an other inconvenient: performance.

Say I have a ready newC object that should replace the older one. Instead of doing G1.C = newC I should do foreach T in foreach P in C replace with T from P from newC.

Is there an other more optimal way to do it?

0

精彩评论

暂无评论...
验证码 换一张
取 消