A 100% Java-based project that simulates a hierarchical file system, demonstrating core Software Design Patterns to manage file and folder operations, including dynamic features like encryption and compression.
- Hierarchical file and folder system
- Runtime file decoration (encryption, compression)
- Depth-First traversal of file system
- Clean separation using design patterns
This project is structured around key object-oriented design patterns to ensure modularity, flexibility, and maintainability:
- Composite Pattern: Files (
FileItem) and folders (FolderItem) are treated uniformly through theFileComponentabstract class, allowing the creation of a tree-like hierarchy. - Decorator Pattern: The system dynamically adds responsibilities (e.g., encryption, compression) to files at runtime using
EncryptedFileandCompressedFiledecorators, without modifying the core file classes.
- Iterator Pattern: Implements the
VFSIteratorfor traversing the entire file system hierarchy using a Depth-First Search (DFS) algorithm.
- Facade Pattern: The
FileSystemFacadesimplifies complex system interactions (like moving files or creating deep structures) for the client code (Main.java).
SCD Lab Project/
│
├── src/vfs/
│ ├── Main.java # Application entry point and client demo
│ ├── FileSystemFacade.java # Facade: simplifies high-level FS operations
│ ├── FileComponent.java # Composite: base abstract class
│ ├── FileItem.java # Composite: concrete leaf (regular file)
│ ├── FolderItem.java # Composite: concrete composite (directory)
│ ├── FileDecorator.java # Decorator: base abstract class
│ ├── EncryptedFile.java # Decorator: adds encryption functionality
│ ├── CompressedFile.java # Decorator: adds compression functionality
│ ├── VFSNode.java # Interface for display/traversal
│ └── VFSIterator.java # Iterator: custom DFS traversal
│
└── README.md
- Java Development Kit (JDK) 8 or higher
Compile the source files into a bin directory:
javac -d bin src/vfs/*.javaRun the compiled application:
java -cp bin vfs.MainThe program outputs the initial structure, demonstrates file movement, and shows the effects of decorators.
Initial File System:
+ root
- hello.txt
+ Documents
- notes.txt
After moving hello.txt to Documents:
+ root
+ Documents
- notes.txt
- hello.txt
Decorators Demo:
- (Encrypted) secret.txt
Decrypting secret.txt...
Opening decrypted file!
Opening compressed file:
Decompressing report.pdf...
Opening decompressed file!
Final File System:
+ root
+ Documents
- notes.txt
- hello.txt
- Add a new file type or decorator
- Create a new class extending
FileDecorator(similar toEncryptedFileorCompressedFile) - Implement
display()andopen()methods for the new behavior - Apply the decorator to files in
Main.java
- Add more file system operations such as
deleteFile(),renameFile(), orcopyFile()inFileSystemFacade - Enhance the iterator with BFS or file-type filtering
- Improve output formatting using icons or tags like
[FOLDER]and[FILE]
Aazain Jan
This project was created as part of my Software Construction & Development (SCD) coursework Fall 2025