about:navigating_principle_languages
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
about:navigating_principle_languages [2013-09-14 15:55] – code DataImpl christian | about:navigating_principle_languages [2013-09-16 17:27] (current) – decision christian | ||
---|---|---|---|
Line 38: | Line 38: | ||
==== Context ==== | ==== Context ==== | ||
- | The following example shows the usage of the OOD Principle Language. It details the assessment of a solution found in the CoCoME system((http:// | + | The following---rather sophisticated---example shows the usage of the OOD Principle Language. It details the assessment of a solution found in the CoCoME system((http:// |
In CoCoME there is a mechanism for getting access to other components. In a nutshell it works like this: | In CoCoME there is a mechanism for getting access to other components. In a nutshell it works like this: | ||
Line 93: | Line 93: | ||
==== Finding a Characterizing Set ==== | ==== Finding a Characterizing Set ==== | ||
- | {{ : | + | {{ : |
We will examine this question using the OOD principle language. First we have to find suitable starting principles. This is one of the rather sophisticated cases where finding a starting principle is at least not completely obvious. If we don't have a clue where to start, we'll have a look at the different categories of principles in the language. Essentially the " | We will examine this question using the OOD principle language. First we have to find suitable starting principles. This is one of the rather sophisticated cases where finding a starting principle is at least not completely obvious. If we don't have a clue where to start, we'll have a look at the different categories of principles in the language. Essentially the " | ||
Line 164: | Line 164: | ||
So LC, RoE and TdA/IE are against the solution, KISS thinks it's good and ML has nothing against it. As it is not the number of principles which is important, the designer still has to make a sound judgment based on these results. What is more important: Coupling, testability, | So LC, RoE and TdA/IE are against the solution, KISS thinks it's good and ML has nothing against it. As it is not the number of principles which is important, the designer still has to make a sound judgment based on these results. What is more important: Coupling, testability, | ||
+ | |||
+ | ==== Deciding between Alternatives ==== | ||
+ | |||
+ | In the next step we would think about better alternatives and might come up with [[patterns: | ||
+ | |||
+ | We already constructed a characterizing set. So the only thing to do is to rate the ideas according to the principles: | ||
+ | |||
+ | The current " | ||
+ | |||
+ | * LC | ||
+ | * DI > SL > F | ||
+ | * Note that in the SL approach there is an additional coupling to the service locator | ||
+ | * KISS | ||
+ | * F > DI = SL | ||
+ | * All three solutions are rather simple but in DI there is complexity for passing around the references and in the SL approach there is complexity in maintaining the registry | ||
+ | * RoE | ||
+ | * The rating of RoE depends on the concrete variant of the pattern. In the DI approach the dependencies are explicitly visible on the interface, which is not the case in the two other approaches. In solution F the dependency is not visible from the interface at all. Same with SL if the service locator is globally accessible. Even if a reference to the service locator is explicitly passed around, it is still not visible which services provided by the locator are used. On the other hand getting a reference is explicit with F and SL. In the DI approach it is only explicit when it is done manually. Typical DI frameworks wire the instances implicitly. | ||
+ | * TdA/IE | ||
+ | * DI > SL = F | ||
+ | * For SL and F one first has to ask for an instance for calling a method on it. In DI the instance is already known, i.e. set from the outside. | ||
+ | * ML | ||
+ | * F > DI > SL | ||
+ | * In the DI solution a possible fault would be to have different modules reference different instances of the same class where they should rather reference the same instance. In SL solution there is even a more problematic fault which could be introduced. Eventually somebody might get the idea to change the registered instances in the locator at runtime. This would then be the source for some hard to find defects: Some modules will cache the instance they got from the service locator in an attribute and some won't. In such a case the latter will receive the new instance while the former won't. | ||
+ | |||
+ | As you can see all three possibilities have their advantages and disadvantages. The designer now has to weight the aspects in order to get to a decision. In this case we might state the following: | ||
+ | |||
+ | * F is ruled out because it is not testable. The other two approaches have lower couplings (LC) which make them better testable. The advantages wrt. KISS and ML do not justify that liability. | ||
+ | * The solutions DI and SL are not very far apart but DI is slightly better wrt. LC, TdA/IE and ML. | ||
+ | * TdA/IE can be regarded less important because it is a heuristic which is normally applied in other situations. | ||
+ | * For RoE we also have to decide whether to use a framework or not. In CoCoME we would rather want to avoid a framework because the rest of the system is implemented in that way ([[principles: | ||
+ | |||
+ | Based on this weighting, we decide to use DI. |
about/navigating_principle_languages.txt · Last modified: 2013-09-16 17:27 by christian