General Responsibility Assignment Software Patterns.
- Who is responsible for creating an object?
- Making it apparent which objects are responsible for creating other objects.
- MVC. Should separate view from model (business logic). Use Controller to coordinate this.
- When the behavior does not belong anywhere else, create a new class.
- A class should be responsible for itself, that if there is a responsibility–and we are asking where does this go–we give it to the class that has the most information needed to fulfill it.
- Cohesion is a measure of how focused the internal behavior of a class is.
- Are all its behaviors related to that single responsibility? If so, it has HIGH COHESION.
- What we want is HIGH COHESION.
- The idea that we can decrease coupling between objects. If you have multiple objects that need to talk to each other, it’s very easy to have HIGH COUPLING between them where there is a lot of dependencies.
- And what we can do instead is reduce those direct connections and put an indirection object in between them to simplify the amount of connections that each object has to make.
- Reduce the amount of required connections between objects.
- The aim is for LOW COUPLING, reducing dependencies.
- Objects do need to know about each other, but as much as possible they should do what they can with the minimum of other objects–as many as necessary but as few as possible.
- Automatically correct behavior based on type.
- How to design a system so that changes and variations have the minimum impact on what already exists.
- We try to identify the most likely points of change so we can make doubly sure that we create a framework around our application that protects the most sensitive pieces.