ITK/Design Principles: Difference between revisions
No edit summary |
|||
Line 6: | Line 6: | ||
== Modes vs Objects == | == Modes vs Objects == | ||
'''Modes''' here refer to the option of enabling alternative behaviors in a class by introducing flags (booleans or enums) that switch the class behavior at run time. | |||
'''Objects''' here refer to the option of implementing alternative behaviors by introducing a family of classes where each class implement one and only one specific behavior. | |||
Guideline: | |||
'''Modes''' should be preferred over '''Objects''' when it is anticipated that a common use case, is to change those behaviors at run time during the use of an application. | |||
'''Objects''' should be preferred over '''Modees''' when it is anticipated that the choices will be made at compilation time and that rarely need to be changed at run time. |
Revision as of 15:50, 2 June 2011
This page contains the software design principles adopted in the Insight Toolkit (ITK)
Object Oriented
Modes vs Objects
Modes here refer to the option of enabling alternative behaviors in a class by introducing flags (booleans or enums) that switch the class behavior at run time.
Objects here refer to the option of implementing alternative behaviors by introducing a family of classes where each class implement one and only one specific behavior.
Guideline: Modes should be preferred over Objects when it is anticipated that a common use case, is to change those behaviors at run time during the use of an application.
Objects should be preferred over Modees when it is anticipated that the choices will be made at compilation time and that rarely need to be changed at run time.