Join Jungwoo Ryoo for an in-depth discussion in this video Other qualities, part of Python: Design Patterns.
- The use of design patterns also promote the Other ideal Qualities of software, such as completeness and correctness. Completeness refers to: how much does a software solution meets its requirement? Since design patterns are community-driven, and they are validated with respect to the desired requirements, you can safely assume that the baseline requirements are met by them. However, one thing to note is that design patterns are intentionally under-defined to allow potential customization, and extension efforts.
Correctness is another important quality of well-developed software. If the software produces incorrect results, although it does most of what it is expected to do, it is still problematic, since the error can lead to catastrophic results, such as loss of human lives, and monetary loss. This Correctness quality is especially important in Mission-critical systems, such as power plants, and water-treatment facilities.
Coupling and Cohesion are also what design patterns address. Coupling means how much different elements of your software are related. If there is strong Coupling within the software elements, changes in one element affect the others significantly, which means a lot of additional work. On the other hand, Cohesion refers to how independent a software component is. Therefore, more Cohesion is better, while less Coupling is desirable, which is the goal of design patterns! Simplicity and Generality Trade-Offs are the last thing I'd like to point out.
The Trade-Off between Simplicity and Generality is also what design patterns consider. For Wider adoption, design patterns may attempt to satisfy too many requirements, and end up being too complicated for it to be truly useful. Although, it is important to be general enough for re-usability purposes. Design patterns also need to be simple enough to be quickly mastered, and highly usable, for Practitioners.
When considering to use design patterns, keep in mind these ideal design qualities, to ensure that you're actually improving the quality of your software by adopting them.
- Understanding design patterns
- Best design practices: consistency, completeness, and correctness
- Working with creational patterns
- Working with structural patterns
- Working with behavioral patterns
Skill Level Intermediate
Q: In the strategy pattern example, why does the code keep executing the default function rather than the alternate?
A: The programming demonstration skips the step of defining what the strategy pattern should be when an alternate function name is provided
as an argument as shown below.