Design a File Sharing Platform

0%

Editorial Solution

Requirements

Define Core Objects

Analyze Relationships

Establish Hierarchy

FileSystemItem Hierarchy (Composite Pattern)

AccessLevel Enum

Why FileVersion is Not in a Hierarchy

Why Comment is Not in a Hierarchy

Design Patterns

Composite Pattern: Uniform File/Folder Operations

Strategy Pattern: Pluggable Storage Backends

Observer Pattern: Collaboration Notifications

Proxy Pattern: Centralized Access Control

Define Class Members (write code)

Enums

User and StorageQuota

FileSystemItem (Abstract Base)

FileVersion (Immutable Snapshot)

FileItem (Thread-Safe Versioning)

Folder (Composite Container)

Permission, SharedLink, and Comment

StorageBackend (Strategy Interface)

FileService (Facade)

Run and Test

Adhere to SOLID Guidelines

Consider Scalability and Flexibility

Thread-Safe File Versioning: The Core Concurrency Challenge

Atomic Quota Updates

Scaling Beyond a Single JVM

Create/Explain your diagram(s)

Future improvements

Table of Contents

Requirements

Define Core Objects

Analyze Relationships

Establish Hierarchy

FileSystemItem Hierarchy (Composite Pattern)

AccessLevel Enum

Why FileVersion is Not in a Hierarchy

Why Comment is Not in a Hierarchy

Design Patterns

Composite Pattern: Uniform File/Folder Operations

Strategy Pattern: Pluggable Storage Backends

Observer Pattern: Collaboration Notifications

Proxy Pattern: Centralized Access Control

Define Class Members (write code)

Enums

User and StorageQuota

FileSystemItem (Abstract Base)

FileVersion (Immutable Snapshot)

FileItem (Thread-Safe Versioning)

Folder (Composite Container)

Permission, SharedLink, and Comment

StorageBackend (Strategy Interface)

FileService (Facade)

Run and Test

Adhere to SOLID Guidelines

Consider Scalability and Flexibility

Thread-Safe File Versioning: The Core Concurrency Challenge

Atomic Quota Updates

Scaling Beyond a Single JVM

Create/Explain your diagram(s)

Future improvements

A file sharing platform looks straightforward on the surface: upload a file, share a link, let someone download it. But beneath that simplicity lies a system that must handle hierarchical folder structures, fine-grained permission control, version tracking across concurrent edits, storage quota enforcement, and pluggable storage backends. Let's decompose the requirements carefully.

Interview Dialogue

CandidateShould the platform support file versioning?
InterviewerClick to reveal answer
CandidateWhat kind of permission model do we need?
InterviewerClick to reveal answer
CandidateShould we support shareable links?
InterviewerClick to reveal answer
CandidateDo users have storage quotas?
InterviewerClick to reveal answer
CandidateShould we handle real-time collaborative editing?
InterviewerClick to reveal answer
Show all answers

Functional Requirements

  1. File Upload and Organization: Users upload files of various types (documents, images, videos, archives). The system stores the content, records metadata (name, type, size), and allows organizing files into a hierarchical folder structure with arbitrary nesting depth.
  2. Sharing: Items can be shared in two ways. First, by generating a shareable link with optional expiration and password protection. Second, by granting access directly to a specific user with a defined access level.
  3. Permission Management: Every shared item carries one of three access levels: VIEW (read-only), EDIT (modify content), or ADMIN (manage permissions, delete). Permissions are enforced on every operation, and they inherit through the folder hierarchy so that sharing a folder automatically shares everything inside it.
  4. Version Control: Every modification to a file creates a new immutable version. Users can view version history, compare versions, and revert to a previous version. Version numbers must be strictly sequential even under concurrent edits.
  5. Download: Any user with at least VIEW permission can download the current version of a file or a specific historical version.
  6. Collaboration: Users can leave comments on files for asynchronous collaboration. Comments are associated with a specific file and author.

Non-Functional Requirements

  • Thread Safety: Concurrent edits to the same file must produce a consistent version chain. Two users uploading simultaneously should each get a distinct, correctly numbered version without data corruption.
  • Extensibility: New storage backends (local disk, S3, GCS) should be pluggable without modifying core business logic. Adding new file types should not require changes to existing classes.
  • Storage Quotas: Each user has a storage limit. Uploads that would exceed the quota must be rejected, even when two uploads happen concurrently against the same quota.

Start by scanning the requirements for nouns. Each one is a candidate class. "Files" and "folders" in a "hierarchical structure" point to an abstract FileSystemItem with FileItem and Folder subclasses (the Composite pattern). "Versions" that are "immutable" with "version number, uploader, timestamp" become the FileVersion class. "Permissions" with "VIEW, EDIT, ADMIN" access levels give us the Permission object. "Shareable links" with "expiration and password" map to SharedLink. "Storage quotas" tracking "consumed versus allocated" become StorageQuota. Not every noun survives. "Download" is an operation rather than a class, but the nouns give you a strong starting lineup to refine.

Let's walk through a typical user session and discover the objects naturally.

A user opens the platform and navigates their file tree. Right away, we need a way to represent both files and folders uniformly. A folder can contain files and other folders, and operations like "get total size" or "search by name" should work the same way regardless of depth. This points to the Composite pattern: an abstract FileSystemItem base class with two concrete subclasses, FileItem and Folder. The base class holds common properties: id, name, owner, timestamps, a permissions list, and a reference to the parent folder.

The user uploads a document. The system stores the content, assigns a version number, and records who uploaded it and when. This version snapshot needs to be its own object because the same file will have many versions over time. That gives us FileVersion, which is immutable once created: it holds a version number, the uploader, timestamp, file size, storage URL, and an optional change description. FileItem maintains an ordered list of these versions and a pointer to the current one.

Now the user wants to share the file with a colleague. There are two sharing mechanisms. Direct sharing creates a Permission object linking a user to a FileSystemItem with an access level (VIEW, EDIT, or ADMIN). Link-based sharing creates a SharedLink with an optional expiration and password. Both reference the FileSystemItem they protect.

The colleague opens the shared file and leaves a comment. That gives us Comment, which ties a user's remark to a specific FileItem with a timestamp.

Behind the scenes, every user has a StorageQuota that tracks how much storage they have consumed out of their allocation. Uploads check this quota before proceeding.

Finally, we need a FileService facade that orchestrates high-level operations: upload a file (check quota, store content, create version), create a folder, share an item (verify permissions first), and generate share links. This keeps domain objects focused on their own state while the service handles cross-cutting workflows.

Notice that the User class itself is simple: an id, name, email, and a reference to their StorageQuota. The interesting behavior lives in the domain objects (FileItem, Folder, Permission) rather than in User.

Key Insight

Why a separate Composite pattern class instead of combining its responsibilities into FileSystemItem? Each class should have one reason to change. If FileSystemItem handled both its own logic and Composite pattern logic, a change to either concern would risk breaking the other.

The relationships in a file sharing platform have some subtle distinctions that are worth getting right, especially around ownership versus reference semantics.

Does Folder own its children, or just reference them?

Think about what happens when a folder is deleted. The files inside should be deleted (or at least detached) too. A folder's children do not exist independently of some parent container; every item in the system lives inside exactly one folder (or at the root). This is composition: Folder owns its FileSystemItem children. Removing a child from one folder and adding it to another is a "move" operation, transferring ownership.

Does FileItem own its FileVersions?

Yes, this is composition. Versions are created by the FileItem and have no meaning outside of it. Deleting a FileItem should delete all its versions. The versions list is an ordered, append-only collection managed entirely by the FileItem.

Does FileItem own the StorageBackend?

No. The StorageBackend is a shared infrastructure service. Many FileItems use the same backend. Destroying a FileItem does not destroy the storage system. This is a dependency, not ownership. FileItem calls the backend to retrieve content but does not manage its lifecycle.

Does Permission link User and FileSystemItem?

Permission is an association class. It does not own either the User or the FileSystemItem. Both exist independently. The Permission simply records that a particular user has a particular access level on a particular item. Deleting a Permission does not delete the user or the item.

How does the Composite pattern work here?

The Composite pattern lets clients treat FileItem and Folder uniformly through the FileSystemItem reference. When you call getSize() on a Folder, it recursively sums the sizes of all children. When you call hasAccess(), it checks local permissions and then recurses up to the parent folder. The client never needs to check instanceof; it just calls the method and polymorphism handles the rest.

How does permission inheritance flow?

When hasAccess(user, level) is called on a FileSystemItem, it first checks if the user is the owner (implicit ADMIN). Then it checks the item's local permission list. If neither matches, it recurses to the parent folder. This means granting EDIT on a folder automatically grants EDIT on every file and sub-folder inside it, without creating individual Permission records. This is a key design insight: the tree structure doubles as the permission propagation mechanism.

Key Insight

Why immutable FileVersion objects instead of mutable version records? If a version could be modified after creation, someone could silently alter the content of a past version. Immutability guarantees that version 3 is exactly what was uploaded as version 3 - the audit trail is tamper-proof by construction.

The file sharing platform has one primary hierarchy rooted in the Composite pattern, plus a supporting enum and several flat classes that collaborate with the hierarchy.

FileSystemItem Hierarchy (Composite Pattern)

The FileSystemItem abstract class is the component in the Composite pattern. It declares:

The two concrete implementations serve very different purposes:

  • FileItem (Leaf) holds file content through its version chain. getSize() returns the current version's byte count. It adds file-specific behavior: upload(), download(), revertToVersion(), addComment(), and getVersionHistory().
  • Folder (Composite) holds a List<FileSystemItem> of children. getSize() recursively sums children's sizes. It adds container-specific behavior: addItem(), removeItem(), and search().

Why not a single class with a type flag?

Because the behaviors diverge significantly. Files have versions, comments, and synchronized upload. Folders have children, recursive size computation, and depth-first search. A type flag would mean every method starts with if (isFolder), which violates OCP and creates a maintenance burden when adding new item types.

AccessLevel Enum

Each AccessLevel constant carries an explicit numeric level: VIEW(1), EDIT(2), ADMIN(3). The hasAccess() method compares these levels with a single >= check: if you have EDIT and need VIEW, EDIT.getLevel() >= VIEW.getLevel() is true. If you have VIEW and need EDIT, it correctly returns false. Using explicit levels instead of ordinal() means the logic survives if someone reorders the enum constants.

Why FileVersion is Not in a Hierarchy

You might consider creating a hierarchy for different file types: DocumentVersion, ImageVersion, VideoVersion. In practice, the version itself is just a storage snapshot; the type-specific behavior (thumbnail generation, transcoding) belongs in processing services, not in the version object. Keeping FileVersion flat and immutable makes the version chain simple and reliable.

Why Comment is Not in a Hierarchy

Similarly, you might envision ThreadedComment, ReviewComment, etc. For this design scope, a flat Comment class with user, text, and timestamp is sufficient. If threading is needed later, adding a parentCommentId field extends the design without requiring a hierarchy.

Key Insight

Why a flat FileVersion class instead of DocumentVersion, ImageVersion, and VideoVersion subclasses? The version is a storage snapshot - it holds a URL, size, and timestamp. Type-specific processing (thumbnails, transcoding) belongs in separate services. Adding subclasses for data-only differences creates classes without new behavior.

Let me walk through each pattern by showing the problem it solves and what breaks without it.

Composite Pattern: Uniform File/Folder Operations

The core problem: files and folders look similar from the outside (both have names, sizes, permissions) but behave differently inside. Without the Composite pattern, every piece of code that operates on "something in the file system" needs to check instanceof and branch. Want to calculate a folder's size? Check every child: is it a file? Get its size. Is it a folder? Recurse. This scatters type-checking logic everywhere.

The Composite pattern solves this by giving FileItem and Folder a shared interface through FileSystemItem. The client calls item.getSize() and does not care which subclass it is:

java
1// Folder recursively computes size via Composite
2public long getSize() {
3  long total = 0;
4  for (FileSystemItem child : children) {
5    total += child.getSize(); // polymorphic dispatch
6  }
7  return total;
8}

The same uniformity applies to hasAccess(), share(), and delete(). The caller never branches on type.

Key Insight

The Composite pattern is the foundation of the entire file sharing design. By giving FileItem and Folder a shared FileSystemItem interface, every operation (size calculation, permission checks, sharing) works uniformly through polymorphic dispatch. Without it, instanceof checks would infect every method that touches the file tree.

Strategy Pattern: Pluggable Storage Backends

A file sharing platform might start on local disk and later move to S3 or Google Cloud Storage. If storage logic is embedded in FileItem, every backend change requires modifying the domain class. The Strategy pattern extracts storage into an interface:

Implementations like LocalStorageBackend, S3StorageBackend, and GCSStorageBackend each handle the specifics. The rest of the system depends only on the interface. Swapping backends is a configuration change, not a code change.

Observer Pattern: Collaboration Notifications

When a file is modified or a comment is added, collaborators need to be notified. Without the Observer pattern, the upload() method would directly call an email service, a push notification service, and an in-app notification service. Every new notification channel means modifying upload().

The Observer pattern decouples this. FileItem publishes events (FileModifiedEvent, CommentAddedEvent), and subscribers (email notifier, push notifier, activity logger) react independently:

java
// In FileItem.upload(), after creating the version:
eventBus.publish(new FileModifiedEvent(this, version));

Adding SMS notifications means adding a subscriber, not touching FileItem.

Proxy Pattern: Centralized Access Control

You could check permissions inside every method: upload() checks EDIT, download() checks VIEW, delete() checks ADMIN. But this scatters access control across the entire codebase. A PermissionProxy wrapping FileSystemItem intercepts every operation, verifies the caller's access level, and delegates to the real object only if authorized. This centralizes security logic in one place.

Common Pitfall

Do not scatter permission checks inside FileItem.upload(), FileItem.download(), and Folder.addItem() individually. Missing a single check creates a security hole. Use a PermissionProxy that intercepts all operations at one point, guaranteeing consistent enforcement even when new methods are added later.

Level Expectations

Junior: explain Composite for uniform file/folder operations and Strategy for pluggable storage backends.

Mid-level: add Proxy for centralized access control and show how Observer decouples modification events from notification delivery.

Senior: discuss how these four patterns compose to create a system where adding a new item type, storage backend, or notification channel each require zero changes to existing code.

Let's build the file sharing platform in Java. I will call out the design decisions that matter most and the concurrency pitfalls you would encounter with simpler alternatives.

Enums

Each AccessLevel carries an explicit numeric level: VIEW(1), EDIT(2), ADMIN(3). This lets hasAccess() use a simple getLevel() comparison to check whether a granted level meets or exceeds the required level, without relying on fragile declaration-order ordinals.

User and StorageQuota

StorageQuota uses AtomicLong with compareAndSet() for lock-free, thread-safe quota tracking. This is important: two concurrent uploads by the same user could both pass a simple if (used + size <= total) check and collectively exceed the quota. The CAS loop ensures only one succeeds if the limit would be exceeded.

FileSystemItem (Abstract Base)

Interview Tip

In a live interview, write FileSystemItem first with getSize() as abstract, then show Folder.getSize() recursing through children. This immediately demonstrates the Composite pattern in action. Follow with hasAccess() to show permission inheritance walking up the parent chain.

The hasAccess() method implements permission inheritance by recursing to the parent folder. This is the mechanism that makes sharing a folder automatically share all its contents.

FileVersion (Immutable Snapshot)

FileItem (Thread-Safe Versioning)

The upload() and revertToVersion() methods are synchronized. This is the core concurrency mechanism. Without synchronization, two threads uploading simultaneously could both read versions.size() as 2, both create version 3, and the version chain would be corrupted. The synchronized keyword ensures only one thread at a time can read the count, increment it, create the version, and update currentVersion.

Folder (Composite Container)

The search() method performs a depth-first traversal, checking each child's name against the query. When a child is a Folder, it recurses. This is the Composite pattern in action: the Folder does not need special handling for sub-folders versus files in its children list.

StorageBackend (Strategy Interface)

FileService (Facade)

The FileService orchestrates cross-cutting operations. Notice that shareItem() verifies the caller has ADMIN access before granting permissions. This prevents a user with VIEW access from escalating their own or others' privileges.

Run and Test

Browse the complete solution code and run it. Try modifying the code to experiment with the design.

Loading editor...

Single Responsibility Principle

Each class in the design has one focused reason to change:

  • FileItem manages file content and versioning. If version numbering logic changes, only FileItem is affected.
  • Permission encapsulates a single user-item access grant. If access level rules change, only Permission and AccessLevel are affected.
  • SharedLink handles URL-based sharing with expiration and password. If link expiration policy changes, only SharedLink is affected.
  • StorageQuota tracks per-user storage usage. If quota tiers or enforcement rules change, only StorageQuota is affected.
  • FileService coordinates cross-cutting workflows. If the upload workflow changes (e.g., adding virus scanning), only FileService is affected.
  • Folder manages the parent-child hierarchy. If search algorithm changes, only Folder is affected.

Open/Closed Principle

The design is open for extension in three specific dimensions:

  1. New item types: Adding a SymLink or ShortcutItem means creating a new FileSystemItem subclass. Folder, Permission, SharedLink, and FileService require no changes because they depend on the abstract base class.
  2. New storage backends: Creating S3StorageBackend implements the StorageBackend interface. FileItem and FileService are unaffected.
  3. New notification channels: Adding an SMS notifier subscribes to the event bus. FileItem publishes events without knowing who listens.
Interview Tip

When demonstrating OCP, walk through a concrete scenario: 'To migrate from local disk to S3, I create S3StorageBackend implementing StorageBackend. FileItem, FileService, FileVersion, Folder, Permission: none of them change.' Listing the unchanged classes by name is more convincing than saying 'nothing changes.'

Liskov Substitution Principle

FileItem and Folder are both valid substitutes for FileSystemItem. The proof: getSize() works correctly on both (FileItem returns its version size; Folder recursively sums children). hasAccess() works on both (both check owner, then permissions, then parent). share() works on both. delete() works on both. The Composite pattern fundamentally depends on LSP; if either subclass broke the contract, the entire recursive traversal would fail.

Interface Segregation Principle

The StorageBackend interface has exactly two methods: store() and retrieve(). It does not force implementations to support listing, deleting, or searching. If those operations are needed, they belong on a separate interface (e.g., StorageManager). This keeps each backend implementation focused.

Dependency Inversion Principle

FileService depends on the abstract FileSystemItem type, not on concrete FileItem or Folder. When shareItem() receives a FileSystemItem, it does not care whether it is a file or folder. Storage operations go through the StorageBackend interface, so swapping from local storage to S3 requires no changes to the domain layer. High-level orchestration (FileService) depends on abstractions (FileSystemItem, StorageBackend), not on concretions.

Thread-Safe File Versioning: The Core Concurrency Challenge

This is the area an interviewer is most likely to probe, because it is where real file sharing systems fail if designed carelessly.

The race condition in detail: FileItem has 2 versions. User A and User B both upload a new version simultaneously. Without synchronization, both threads read versions.size() as 2, both compute nextVersion = 3, both create a FileVersion with versionNumber = 3, and both add it to the list. The result: two versions numbered 3, a corrupted version chain, and ambiguity about which is the "real" version 3.

The synchronized solution: Making upload() synchronized on the FileItem instance means only one thread at a time can execute the read-increment-create-update sequence. Thread A acquires the lock, reads size=2, creates version 3, adds it, releases the lock. Thread B acquires the lock, reads size=3, creates version 4. Each version gets a unique sequential number.

Why not ReentrantLock? For FileItem, synchronized is sufficient because we only need mutual exclusion on a single object. There is no scenario analogous to the ATM's two-account transfer where we need to lock two FileItems simultaneously. If such a scenario arose (e.g., moving a file between two folders atomically), ReentrantLock with ordered locking would be appropriate.

Key Insight

Synchronized on FileItem.upload() protects per-file versioning, while AtomicLong CAS protects per-user quota. These are two different granularities of thread safety solving two different problems. Choosing the right synchronization primitive for each granularity is what separates a correct concurrent design from an over-locked one.

Atomic Quota Updates

StorageQuota uses AtomicLong with compareAndSet() instead of synchronized methods. This provides lock-free thread safety, which is advantageous because quota checks happen frequently and contention is typically low. The CAS loop retries if another thread modified the value between the read and the update, ensuring no two concurrent uploads collectively exceed the limit.

The tradeoff: CAS loops can spin under high contention. If many threads are uploading simultaneously for the same user, LongAdder or a synchronized approach might perform better. For typical workloads, CAS is optimal.

Scaling Beyond a Single JVM

Database-backed versioning: In production, the synchronized keyword on upload() only protects within one JVM. With multiple servers, you need database-level concurrency control. Two approaches:

  1. Optimistic locking: Each FileItem row has a version stamp. On upload, the system reads the stamp, creates the new version, and writes with WHERE version_stamp = ?. If another server updated first, the write fails and the operation retries.
  2. Database sequences: Use an auto-increment column for version numbers. The database guarantees uniqueness, removing the need for application-level synchronization entirely.

Storage tier separation: Move file content to object storage (S3, GCS) and metadata to a relational database. The StorageBackend Strategy pattern makes this migration transparent to the domain layer.

CDN integration: For frequently downloaded files, serve content through a CDN. FileVersion's storageUrl already abstracts the retrieval location; switching to a CDN URL requires no domain changes.

Permission caching: The hasAccess() recursive walk up the folder tree works well in memory, but becomes expensive with deep nesting in a database-backed system. Caching effective permissions per user-item pair, with invalidation when ancestor permissions change, is the production solution.

Sharding by user: For massive scale, shard the file metadata database by user ID. Each user's file tree lives on a specific shard. Shared files reference items across shards via a sharing service, introducing eventual consistency but enabling horizontal scaling.

Level Expectations

Junior: explain the version-number race condition and how synchronized on upload() prevents it.

Mid-level: compare synchronized vs. optimistic locking for multi-server deployments and discuss CAS-based quota tracking.

Senior: design the sharding strategy for file metadata, including cross-shard permission resolution for shared files and CDN integration for downloads.

Below is the class diagram showing the file sharing platform architecture.

Key points to highlight in an interview:

  • The Composite pattern (FileSystemItem as abstract base, FileItem as leaf, Folder as composite) enables uniform treatment of files and folders. getSize(), hasAccess(), and share() work polymorphically on any item.
  • FileItem owns its FileVersions (composition). Deleting a file deletes all versions. Permission references both User and FileSystemItem (association). Deleting a permission does not delete either.
  • StorageQuota uses AtomicLong for lock-free concurrent quota enforcement. FileItem uses synchronized for thread-safe versioning. Different concurrency mechanisms are chosen based on the specific needs of each class.
  • FileService depends on the StorageBackend interface (DIP), not on any concrete storage implementation. The domain layer is insulated from infrastructure changes.
  • The AccessLevel enum's explicit level field enables efficient permission comparison without switch statements.

Real-Time Collaborative Editing

Integrate Operational Transformation (OT) or Conflict-Free Replicated Data Types (CRDTs) to allow multiple users to edit a document simultaneously. Each user's edits are transformed against concurrent operations to maintain consistency. This would require adding a CollaborationSession class that tracks active editors, a DocumentOperation class representing individual edits (insert, delete, format), and a ConflictResolver that applies the OT or CRDT algorithm. The existing FileVersion model still applies: collaborative sessions periodically checkpoint into new immutable versions.

Content Deduplication via File Hashing

Hash file contents (SHA-256) on upload and check whether identical content already exists in storage. If it does, the new FileVersion points to the same storageUrl as the existing copy instead of storing duplicate bytes. This can dramatically reduce storage costs: if 100 users upload the same company template, only one copy is stored. Implementation adds a ContentHashIndex class that maps hash digests to storage URLs. StorageQuota would need adjustment to track logical usage (what the user uploaded) separately from physical usage (what is actually stored).

File Preview Generation

Asynchronously generate thumbnails for images, PDF previews for documents, and video previews using a background worker pool. Introduce a PreviewGenerator interface with implementations for each content type (ImagePreviewGenerator, PdfPreviewGenerator, VideoPreviewGenerator). Previews are cached and served via CDN. The Strategy pattern already in place for StorageBackend applies naturally here: the system selects the right generator based on file type without conditional logic.

End-to-End Encryption

Encrypt files client-side before upload so that even the server cannot read file contents. Each user has a public/private key pair. When sharing, the file's encryption key is encrypted with the recipient's public key and attached to the Permission. This requires adding EncryptionKey and KeyManager classes. The StorageBackend stores only encrypted bytes. The tradeoff is that server-side features like search, preview generation, and deduplication become impossible on encrypted content.

Activity Audit Log

Track every operation (upload, download, share, delete, revert) with an immutable audit trail. Introduce an AuditEvent class recording the actor, action, target item, timestamp, and outcome. The Observer pattern is ideal: each domain operation publishes an event, and the AuditLogger subscriber persists it. This supports compliance requirements, security investigations, and usage analytics without modifying any existing domain class.

Try this problem yourself

Reading a solution is not the same as producing one under interview pressure. Design it on the whiteboard and get scored feedback.

Concepts used in this design

The building blocks this design relies on, each explained in its own lesson.


Markdown supported

0%

Editorial Solution

Requirements

Define Core Objects

Analyze Relationships

Establish Hierarchy

FileSystemItem Hierarchy (Composite Pattern)

AccessLevel Enum

Why FileVersion is Not in a Hierarchy

Why Comment is Not in a Hierarchy

Design Patterns

Composite Pattern: Uniform File/Folder Operations

Strategy Pattern: Pluggable Storage Backends

Observer Pattern: Collaboration Notifications

Proxy Pattern: Centralized Access Control

Define Class Members (write code)

Enums

User and StorageQuota

FileSystemItem (Abstract Base)

FileVersion (Immutable Snapshot)

FileItem (Thread-Safe Versioning)

Folder (Composite Container)

Permission, SharedLink, and Comment

StorageBackend (Strategy Interface)

FileService (Facade)

Run and Test

Adhere to SOLID Guidelines

Consider Scalability and Flexibility

Thread-Safe File Versioning: The Core Concurrency Challenge

Atomic Quota Updates

Scaling Beyond a Single JVM

Create/Explain your diagram(s)

Future improvements

Table of Contents

Requirements

Define Core Objects

Analyze Relationships

Establish Hierarchy

FileSystemItem Hierarchy (Composite Pattern)

AccessLevel Enum

Why FileVersion is Not in a Hierarchy

Why Comment is Not in a Hierarchy

Design Patterns

Composite Pattern: Uniform File/Folder Operations

Strategy Pattern: Pluggable Storage Backends

Observer Pattern: Collaboration Notifications

Proxy Pattern: Centralized Access Control

Define Class Members (write code)

Enums

User and StorageQuota

FileSystemItem (Abstract Base)

FileVersion (Immutable Snapshot)

FileItem (Thread-Safe Versioning)

Folder (Composite Container)

Permission, SharedLink, and Comment

StorageBackend (Strategy Interface)

FileService (Facade)

Run and Test

Adhere to SOLID Guidelines

Consider Scalability and Flexibility

Thread-Safe File Versioning: The Core Concurrency Challenge

Atomic Quota Updates

Scaling Beyond a Single JVM

Create/Explain your diagram(s)

Future improvements