Interface should be dependent on model

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
m
Line 1: Line 1:
 
:''In applications that consist of an object-oriented model interacting with a user interface, the model should never be dependent on the interface. The interface should be dependent on the model.'' --Riel's Heuristic 3.5, [[Arthur Riel 1996]]
 
:''In applications that consist of an object-oriented model interacting with a user interface, the model should never be dependent on the interface. The interface should be dependent on the model.'' --Riel's Heuristic 3.5, [[Arthur Riel 1996]]
  
This heuristic basically says that the model (i.e. the classes that represent domain concepts) should have no knowledge of the user interface. Instead, the interface should know about the domain classes and it should know how to display them.
+
This heuristic basically says that the model (i.e. the classes that represent domain concepts) should have no knowledge of the user interface. Instead, the interface should know about the domain classes and it should know how to display them. Some flavour of [[Model view controller]] is typically used to accomplish this.
  
 
One of the reasons why it is bad for the model to know about the interface is that it will make it much harder to switch to using a different user interface. If the user interface is changed (e.g. from text-based to graphical) the model will also be affected.  
 
One of the reasons why it is bad for the model to know about the interface is that it will make it much harder to switch to using a different user interface. If the user interface is changed (e.g. from text-based to graphical) the model will also be affected.  
Line 11: Line 11:
 
*[[Circular dependency]]
 
*[[Circular dependency]]
 
*[[Separation of concerns]]
 
*[[Separation of concerns]]
 +
*[[Model view controller]]
  
 
[[Category:Riel's heuristics]]
 
[[Category:Riel's heuristics]]

Revision as of 09:40, 19 October 2010

In applications that consist of an object-oriented model interacting with a user interface, the model should never be dependent on the interface. The interface should be dependent on the model. --Riel's Heuristic 3.5, Arthur Riel 1996

This heuristic basically says that the model (i.e. the classes that represent domain concepts) should have no knowledge of the user interface. Instead, the interface should know about the domain classes and it should know how to display them. Some flavour of Model view controller is typically used to accomplish this.

One of the reasons why it is bad for the model to know about the interface is that it will make it much harder to switch to using a different user interface. If the user interface is changed (e.g. from text-based to graphical) the model will also be affected.

This rule is a more specific version of Circular dependency.

See also

Personal tools