CS FundamentalsHardProduct-company design interview

In GRASP terms, an Order aggregates its LineItems and has the data needed to initialise them. Which class should create LineItem objects, and which principle says so?

  1. A. A separate LineItemFactory, by the Pure Fabrication principle only
  2. B. Order, by the Creator principle (the container that aggregates and initialises the objects creates them)
  3. C. The UI controller, by the Controller principle
  4. D. LineItem itself, by Information Expert

Correct answer: B. Order, by the Creator principle (the container that aggregates and initialises the objects creates them)

Creator assigns creation to a class that contains or aggregates the objects and has their initialising data. Pure Fabrication is used only when no domain class fits well.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic