Challenge: Composite Pattern
Explore how to apply the composite design pattern to implement a directory system in JavaScript. This lesson helps you understand the structure of components, leaves, and composites through a hands-on challenge, enabling you to model files and folders with properties such as name, size, and last modification time.
We'll cover the following...
We'll cover the following...
Problem statement
In this challenge, you have to implement a directory system using the composite pattern.
You have been given the following skeleton code:
It’s up to you to figure out which class will be the component, leaf subclass, and composite subclass.
A Directory has the following properties:
-
name: the name of the file/folder ...