Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Composite Pattern – File System Example (Java)

This repository demonstrates the Composite design pattern using a simple file system–style example written in Java.

The example shows how individual objects (files) and composite objects (folders containing files or other folders) can be treated uniformly through a shared interface.


What Is Being Demonstrated?

The Composite pattern allows you to model tree-structured hierarchies where both:

  • leaf nodes (single objects), and
  • composite nodes (collections of objects)

support the same operations.

In this example:

  • A File is a leaf node
  • A Folder is a composite node
  • Both expose a getSize() operation
  • Client code does not need to know whether it is dealing with a file or a folder

About

Demonstration of the Composite Pattern

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages