Problem statement
Design the object model and public APIs for the editing core of a plain-text editor (think the buffer-and-commands kernel behind a code editor pane, not the widget). The core holds one document, tracks a cursor and an optional selection, applies edits, and lets the user undo and redo those edits step by step.
Operating context. A single document open in one window, driven by one UI thread — no collaboration and no remote sync. The user types characters, deletes with backspace/delete, pastes and cuts spans of text, and moves or extends a selection with the keyboard and mouse. Every mutating action must be undoable, and undone actions must be redoable until the next fresh edit is made. A long typing burst should collapse into a small number of undo steps (pressing undo once should not rewind a single keystroke), yet structural edits like a paste or a cut should each be their own step. The document can reach a few million characters, so an edit must not require rewriting the whole buffer, and the undo history must be bounded so memory does not grow without limit.
Out of scope. Text rendering, layout, fonts and the on-screen widget; file open/save and encoding detection; syntax highlighting, search-and-replace, and multiple cursors; real-time collaboration, operational transform, or CRDTs; persistence of the undo history across sessions.
What to produce. The class hierarchy (document/buffer, cursor and selection, the edit command abstraction and its concrete kinds, and the history manager), the public API each class exposes, and the state transitions of the history as edits, undos, and redos interleave. Be explicit about: how each edit is captured as a reversible command, how the undo and redo stacks evolve (and what happens to the redo stack after a new edit), how consecutive small edits are grouped or coalesced into one undoable unit while structural edits stay separate, and how a brand-new edit kind (for example, a case-transform or an auto-indent) is added without editing the history manager or existing commands.
Requirements
This assessment is a Premium feature.
The statement above is free to read. The functional and non-functional requirements, and the graded canvas that scores your design against them, come with Premium.
Topics
- System Design LLD
- Patterns Command
- Oop Solid
- Statemachine
- Extensibility