Defining the choice of design patterns

When choosing a design pattern, we may want a certain set of characteristics that the design pattern should fulfill. Let's take a look at what these characteristics may consist of if we were to use Python to implement our design pattern:

  • Principle of least astonishment: The Zen of Python says that the principle of least astonishment should be followed. That means that a design pattern being used should not surprise its user in terms of the behavior it is expected to show.
  • Reduced coupling: Coupling is defined as the degree to which the different components inside a software are interdependent on each other. A software with a high degree of coupling may be very hard to maintain, since a change to one component may require a change to a lot of other components. Coupling as an effect cannot be completely removed from the software, but the choice of design pattern should be made such that the degree of coupling can be minimized in the development process.
  • Focus on simplicity: Starting to develop a software with a design principle that is too generalized can do more harm than good. It may introduce a lot of unwanted functionality into the code base, which is used very sparingly or not used at all. The choice of design pattern should be made to focus more on providing a simple solution to the stated problem, rather than with a focus on how many common types of problems a particular design pattern can solve.
  • Avoid duplication: A good choice of design pattern will help the developer to avoid duplicating the code logic and keep it in one place, from where the different components of the system can access it. The reduction in duplication of logic will not only save development time, but will also make the maintenance process easy, where the change in the logic will need to be done only at a single point, and not in multiple parts of the code base.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.17.128