ITK/Design Principles: Difference between revisions

From KitwarePublic
< ITK
Jump to navigationJump to search
No edit summary
 
(2 intermediate revisions by one other user not shown)
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 '''Modes''' when it is anticipated that the choices will be made at compilation time and that rarely need to be changed at run time.

Latest revision as of 01:26, 11 February 2012

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 Modes when it is anticipated that the choices will be made at compilation time and that rarely need to be changed at run time.