Designing a Task Management System
What is the Task Management Problem?
Section titled “What is the Task Management Problem?”Design a comprehensive task management system that allows users to create, edit, delete, assign, and track tasks with various states, priorities, reminders, and history tracking.
In this problem, you’ll design a system that handles task assignments, priority levels, and automatic reminders, all while maintaining a clean history of changes through robust state transitions.
Problem Overview
Section titled “Problem Overview”Design a productivity platform where users can organize their work, collaborate through assignments, and track progress over time.
Core Requirements
Section titled “Core Requirements”Functional Requirements:
- Task CRUD: Create, edit, and delete tasks with title, description, due date, and priority.
- Assignments: Assign and reassign tasks to specific users.
- Reminders: Set notifications to alert users before a task is due.
- Search & Filter: Find tasks by Priority, Due date, Assigned user, and Status.
- Completion & History: Mark tasks as completed; view history of status changes and property modifications.
- Validation: Enforce strict state transitions (e.g., must go through In Progress before Completed).
Non-Functional Requirements:
- Object-Oriented Design: Clear roles for Task, Manager, Notification, and History components.
- Modularity: Easy to add features like subtasks, dependencies, or new filters.
- Thread Safety: Ensure CRUD operations and status updates handle concurrent access without data loss.
- Testability: Core management logic should be highly decoupled and easily unit-testable.
- Observer Integration: Use the Observer Pattern to notify secondary services of task changes.
What’s Expected?
Section titled “What’s Expected?”1. System Architecture
Section titled “1. System Architecture”The system coordinates between the TaskManager, NotificationService, and HistoryTracker.
2. Key Classes to Design
Section titled “2. Key Classes to Design”classDiagram
class Task {
-String id
-String title
-Priority priority
-TaskState state
-User assignee
+changeState(newState)
+assign(user)
}
class TaskState {
<<interface>>
+handle(task)
}
class PendingState {
+handle(task)
}
class HistoryEntry {
-DateTime timestamp
-String changeDescription
-User actor
}
Task o-- TaskState
Task --> User
Task "1" *-- "many" HistoryEntry
TaskState <|-- PendingState
System Flow
Section titled “System Flow”State Transition & Notification Flow
Section titled “State Transition & Notification Flow”Key Design Challenges
Section titled “Key Design Challenges”1. Enforcing Workflow Rules
Section titled “1. Enforcing Workflow Rules”Hardcoding state logic with if-else blocks (e.g., if (status == PENDING && next == COMPLETED) Error) becomes messy as you add more states like “In Review” or “Blocked.”
Solution: Use the State Pattern. Each state is its own class (Pending, InProgress, Completed). The Task delegates the changeState call to the current state object, which knows which transitions are allowed.
2. Decoupled Notifications
Section titled “2. Decoupled Notifications”The Task object shouldn’t need to know how to send an email or log to a database.
Solution: Use the Observer Pattern. The Task is the “Subject.” Various services like ReminderService, AuditLogger, and EmailService are “Observers” that subscribe to task changes. This keeps the core Task class clean and focused.
3. Concurrency and Deadlocks
Section titled “3. Concurrency and Deadlocks”If two managers try to assign the same task to different people at the same time, you could end up with inconsistent data.
Solution: Use Optimistic Locking. Add a version field to the Task. When updating, check if the version in the database matches the version you read. If it doesn’t, another user has modified the task, and you should prompt the user to refresh.
What You’ll Learn
Section titled “What You’ll Learn”By solving this problem, you’ll master:
- ✅ State Management - Enforcing complex, multi-stage workflows.
- ✅ Observer Pattern - Decoupling core logic from side effects.
- ✅ Audit Logging - Building transparent and traceable systems.
- ✅ SOLID Principles - Designing for high cohesion and low coupling.
View Complete Solution & Practice
Section titled “View Complete Solution & Practice”Ready to see the full implementation? Open the interactive playground to access:
- 🎯 Step-by-step guidance through the 8-step LLD approach
- 📊 Interactive UML builder to visualize your design
- 💻 Complete Code Solutions in Python, Java, C++, TypeScript, JavaScript, C#
- 🤖 AI-powered review of your design and code
Related Problems
Section titled “Related Problems”After mastering Task Management, try these similar problems:
- Logging Framework - Another great use of the Observer pattern.
- Ticket Booking System - Resource allocation and state management.
- E-commerce Order Flow - Tracking a purchase through various statuses.