CS FundamentalsHardProduct-company placement
A text editor needs multi-level undo and redo, and also wants to queue and log user actions such as 'insert text' or 'delete line'. Which pattern is the natural fit?
- A. Observer
- B. Memento only
- C. Command, with each action an object that knows how to execute and undo itself
- D. Mediator
Correct answer: C. Command, with each action an object that knows how to execute and undo itself
Command turns each request into an object that can be stored on undo/redo stacks, queued or logged. Memento can help save state for undo but does not by itself model queued, loggable actions.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- A vending machine's behaviour for insertCoin() and selectItem() differs completely in the states Idle, HasCoin, Dispensing and SoldOut…
- A report class defines generate() as: fetchData(); format(); export(). Subclasses PdfReport and CsvReport override only format() and…
- An app must create a consistent family of UI widgets (Button, Checkbox, Menu) for either a Light or a Dark theme, never mixing a Light…
- A game renders 1,000,000 trees. Each tree object stores mesh and texture data (about 2 MB, the same for every oak) plus its own x, y…
- An editor must save snapshots of a document's internal state so it can be restored later, without exposing the document's private fields…
- In an air-traffic system, 20 aircraft objects would each need references to all the others to coordinate landings. Routing every message…