Model the real world

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
m
Line 1: Line 1:
Object Oriented programming is all about modeling the real world. We do this because in theory it is easier to think about how something works, if it exists in the real world. For example, a trivial Car class would be easy to implement, as most people know what a Car is made up of, at a high level sense. Modeling real world objects is considered easier than modeling complex, artificial algorithms and control processes that only exist in the domain of the program they are being developed for. OO also gives programmers a way to decompose a problem into smaller components that "make sense". Of course, this all relies on being able to make good OO models (ie picking classes). The main guideline is to model what actually exists in the real world. For example, Car and Road may be good OO classes, but VehicleAndRoadController probably isn't very good. A class name that has no meaning outside of the computer program it is part of may be a sign you are not modeling the real world. Of course, exceptions will occur in certain domains, and it is not often as easy as just "modeling the real world".
+
:''Model the real world whenever possible. (This heuristic is often violated for reasons of system intelligence distribution, avoidance of god classes, and the keeping of related data and behavior in one place).'' --Riel's Heuristic 3.6, [[Arthur Riel 1996]]
 +
 
 +
Object Oriented programming is all about modelling the real world. We do this because in theory it is easier to think about how something works if it exists in the real world. For example, a trivial ''Car'' class would be easy to implement, as most people know what a car is made up of, at a high level sense. Modeling real world objects is considered easier than modeling complex, artificial algorithms and control processes that only exist in the domain of the program they are being developed for. OO also gives programmers a way to decompose a problem into smaller components that "make sense". Of course, this all relies on being able to make good OO models (ie picking classes). The main guideline is to model what actually exists in the real world. For example, ''Car'' and ''Road'' may be good OO classes, but ''VehicleAndRoadController'' probably isn't very good. A class name that has no meaning outside of the computer program it is part of may be a sign you are not modeling the real world. Of course, exceptions will occur in certain domains, and it is not often as easy as just "modeling the real world".
 +
 
 +
[[Category:Riel's heuristics]]

Revision as of 23:56, 20 July 2009

Model the real world whenever possible. (This heuristic is often violated for reasons of system intelligence distribution, avoidance of god classes, and the keeping of related data and behavior in one place). --Riel's Heuristic 3.6, Arthur Riel 1996

Object Oriented programming is all about modelling the real world. We do this because in theory it is easier to think about how something works if it exists in the real world. For example, a trivial Car class would be easy to implement, as most people know what a car is made up of, at a high level sense. Modeling real world objects is considered easier than modeling complex, artificial algorithms and control processes that only exist in the domain of the program they are being developed for. OO also gives programmers a way to decompose a problem into smaller components that "make sense". Of course, this all relies on being able to make good OO models (ie picking classes). The main guideline is to model what actually exists in the real world. For example, Car and Road may be good OO classes, but VehicleAndRoadController probably isn't very good. A class name that has no meaning outside of the computer program it is part of may be a sign you are not modeling the real world. Of course, exceptions will occur in certain domains, and it is not often as easy as just "modeling the real world".

Personal tools