Hi Sajjad,
That's exactly what I was trying to say. In the "Diagram Scene" example, as you mentioned, QGraphicsScene has been extended because the application has to have its own "specialized" functionality that QGraphicsScene does not provide. In the "Elastic Nodes" example, again as you mentioned, QGraphicsView has been extended because the application has to show "specialized" graphics outcome or user interactions that QGraphicsView does not provide.
By the way, it is not really relevant to claim that elastic node application's graphical quality is better simply because it has extended the QGraphicsView. It is better because it has better rendering implementation. In other words, you can make it have "worse" graphics with a sub class of QGraphicsView (although no one would ever do I reckon). I guess this leads us back to the No. 1 question in Object Oriented Programming. "When do we extend a class?" This is a really big question and I'm afraid I don't have a ultimate answer for the question. In general, I extend a class when things gets too specialized and prevent the re-usability of a class.
For your question, how to decouple Model and View... that is a kind of an software architecture related question. If I dare to answer your question, I guess they are already decoupled in the first place. That's the bottom line of using MVC concept. Model-View-Control classes are all independent (although most of cases it's not entirely true in real world...) I guess Model should never know about View because it has to be absolutely independent from View. This ways a Model can be used by any Views on demands. It's solely up to the Views using the Model how they are going to render. Therefore, I'm not sure whether we can call this as they are "decoupled" because it sounds like in both way they are independent. However, if View is independent from the Model... I think it sounds bit weird because it means the View will never be able to render a Model properly since different Model will have different members.
I guess this discussion would never end =) I'm a kinda guy who doesn't really picky on software architecture and design as long as the software works but we should think of why we keep indenting the source codes. It tells us something doesn't it?I really hope any of above I wrote helps you anyhow.
Regards,





I really hope any of above I wrote helps you anyhow.
Reply With Quote
Bookmarks