Lecture overview -- Keyboard shortcut: 'u'  Previous page: Questions Related to Responsibility -- Keyboard shortcut: 'p'  Next page: The highly responsible program -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 11 : 32
Object-oriented Programming in C#
Contracts and Assertions
Division of Responsibilities

A class manages a certain responsibility

We wish to avoid that a set of classes escape from responsibilities

We also wish to avoid overlapping responsibilities between pair of classes

 

  • Division of responsibilities

    • Without well-defined division of responsibilities

      • All classes accept a large responsibility

      • All program parts check all possible conditions (defensive programming)

      • Makes a large program even larger

    • With well-defined division of responsibilities

      • Operations can safely operate under given assumptions

      • It is well-defined which parts should check which conditions

      • Simplifies the program