Reputation: 127
Can some one help me to find the best approach? Its is documentcloud.
References between Models and Views can be handled several ways.
Thanks!
Upvotes: 2
Views: 133
Reputation: 771
I do believe that 3 is best practice in this case. The observer pattern or subscriber/publisher patterns promotes loose coupling between your objects. This means that your objects has no knowledge about each others implementation details. The benefit of this is that you can more easily change one of your objects later on, for example a method name, without risking that your application breaks somewhere else. This is great for maintainability.
Also, the observer pattern (3) promotes code reuse since you can more easily replace or extend objects in your application. Relying on a specific structure or hierarchy of your application seems like it could counteract reuse of your code within other projects for example.
Upvotes: 6