From Design patterns to Reactive programming
Even though the design pattern movement is aligned with OOP, and reactive programming is aligned towards FP, there are close similarities between them. In a previous chapter(Chapter 5, Introduction to Observables), we learned the following:
- The OOP model is good for modeling the structural aspects of a system.
- The FP model is good for modeling the behavioral aspects of a system.
To illustrate the connection between OOP and reactive programming, we will write a program that will traverse directories to enumerate files and sub-folders within a given folder.
We will create a composite structure that contains the following:
- A
FileNode
(inherits from the abstract class ÂEntryNode
) that models file information - A
DirectoryNode
(inherits from the abstract class ÂEntryNode
) that models folder information
After defining the preceding Composites, we will define Visitors for the following:
- Printing filenames and folder names
- Converting a composite hierarchy to a list...