CS FundamentalsHardProduct-company design interview
In an air-traffic system, 20 aircraft objects would each need references to all the others to coordinate landings. Routing every message through a control-tower object instead is which pattern, and what does it cut the number of object-to-object links to?
- A. Observer; 190 links
- B. Facade; 1 link
- C. Mediator; 20 links (each aircraft talks only to the tower) instead of 190
- D. Chain of Responsibility; 19 links
Correct answer: C. Mediator; 20 links (each aircraft talks only to the tower) instead of 190
A full mesh of 20 objects needs 20 x 19 / 2 = 190 links; with a Mediator each object knows only the mediator, so 20 links. The price is that the mediator can grow into a complex 'god object'.
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
- How many of these differences between Proxy and Decorator are correct? 1. Both implement the same interface as the object they wrap. 2. A…
- A class Invoice has methods calculateTotal(), saveToDatabase() and renderPdf(). Which principle does it violate, and what is the usual fix?
- A Worker interface declares work(), eat() and sleep(). RobotWorker implements it and leaves eat() and sleep() throwing 'not supported'…
- How many of these subclass changes violate the Liskov Substitution Principle? 1. The overriding method accepts a wider range of inputs…
- An area calculator contains if shape.type == "circle": … elif shape.type == "square": …, and every new shape requires editing this…
- How many of these statements are correct? 1. Dependency Inversion is a design principle: high- and low-level modules should both depend on…