CSC/ECE 517 Fall 2007/wiki3 3 ab: Difference between revisions
Jump to navigation
Jump to search
Line 9: | Line 9: | ||
There are several principles of Separation of Responsibility [1]: | There are several principles of Separation of Responsibility [1]: | ||
* Single Responsibility Principle (SRP). Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. | * ''Single Responsibility Principle (SRP)''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. | ||
* Encapsulation. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place. | * ''Encapsulation''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place. | ||
* Expert pattern. The object that contains the necessary data to perform a task should be the object that manipulates the data. | * ''Expert pattern''. The object that contains the necessary data to perform a task should be the object that manipulates the data. | ||
* The Dry principle. Code should not be duplicated. A given functionality should be implemented only in one place in the system. | * ''The Dry principle''. Code should not be duplicated. A given functionality should be implemented only in one place in the system. | ||
==Reference== | ==Reference== |
Revision as of 01:57, 17 November 2007
Topic
Take the principle of Separation of Responsibility and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.
Introduction
Separation of Responsibility
In Object-Oriented Design (OOD), each individual object should have as few responsibilities as possible, ideally one responsibility per object. That is to say,
Principle of Separation of Responsibility
There are several principles of Separation of Responsibility [1]:
- Single Responsibility Principle (SRP). Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation.
- Encapsulation. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.
- Expert pattern. The object that contains the necessary data to perform a task should be the object that manipulates the data.
- The Dry principle. Code should not be duplicated. A given functionality should be implemented only in one place in the system.