Chapter 8. Behavioral Design Patterns – Part 1

Our journey through the Scala design patterns has arrived at the family of behavioral design patterns. This group has more members than the others we already went through, so we will split it into two separate parts. In this chapter, we will focus on the following behavioral design patterns:

  • Value object
  • Null object
  • Strategy
  • Command
  • Chain of responsibility
  • Interpreter

This and the next chapter will give some clarity about what behavioral design patterns are, where they are useful, and how to implement them in Scala. We will be following a path similar to the previous chapters where we presented the patterns, showed a class diagram and a code example, and finally, gave a few hints about what to watch out for and where certain patterns are preferred to be used. Hopefully, you will get a feel of them and be able to confidently identify situations where they are applicable.

What are behavioral design patterns?

Behavioral design patterns, as the name suggests, have to do with behavior. Their purpose is to identify and implement common communication patterns between objects in an application. They define object interaction in such a way that the communication between objects is easy and coupling is still kept at a low level.

Behavioral design patterns describe how objects and classes interact with each other using messages. Contrary to creational and structural design patterns, the behavioral design patterns describe a flow or a process. This means that a developer should be really familiar with the actual process they are trying to implement. As with every other type of design pattern, behavioral design patterns exist in order to increase the testability, maintainability, and flexibility of the produced code.

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

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