Level 1 — RecognitionDesign Principles

Design Principles

20 minutes40 marksprintable — key stays hidden on paper

Subject: Coding — Chapter 2.2 Design Principles Level: 1 (Recognition: MCQ, Matching, True/False with justification) Time Limit: 20 minutes Total Marks: 40


Section A — Multiple Choice (1 mark each, 10 marks)

Choose the single best answer.

Q1. The DRY principle primarily aims to reduce: a) execution time b) duplication of knowledge/logic c) memory usage d) number of classes

Q2. "Keep It Simple" (KISS) advises a developer to: a) always use the newest design pattern b) prefer the simplest solution that works c) add configuration for every case d) avoid all abstraction

Q3. YAGNI ("You Aren't Gonna Need It") warns against: a) writing tests b) building features on speculative future needs c) refactoring d) documenting code

Q4. A class that has more than one reason to change violates the: a) Open/Closed Principle b) Single Responsibility Principle c) Liskov Substitution Principle d) Interface Segregation Principle

Q5. "Software entities should be open for extension but closed for modification" defines the: a) Dependency Inversion Principle b) Open/Closed Principle c) DRY d) KISS

Q6. If subtype objects cannot replace their base type without breaking behaviour, which principle is violated? a) Liskov Substitution b) Interface Segregation c) Single Responsibility d) YAGNI

Q7. "Clients should not be forced to depend on interfaces they do not use" is the: a) Dependency Inversion Principle b) Interface Segregation Principle c) Open/Closed Principle d) Separation of Concerns

Q8. The Singleton pattern belongs to which category? a) Structural b) Behavioral c) Creational d) Architectural

Q9. Which pattern lets an object alter its behaviour when its internal state changes, appearing to change its class? a) Strategy b) State c) Observer d) Command

Q10. The Adapter pattern is used to: a) create families of objects b) make incompatible interfaces work together c) notify observers d) undo commands


Section B — Matching (1 mark each, 12 marks)

Match each pattern in Column X to its correct category in Column Y. Write pairs like Q11 → C.

Column X (Pattern) Column Y (Category)
Q11. Factory Method A. Creational
Q12. Decorator B. Structural
Q13. Observer C. Behavioral
Q14. Proxy
Q15. Builder
Q16. Strategy
Q17. Facade
Q18. Prototype
Q19. Command
Q20. Composite
Q21. Template Method
Q22. Abstract Factory

Section C — True / False WITH Justification (3 marks each, 18 marks)

State True or False (1 mark) and give a one-line justification (2 marks).

Q23. Applying the Dependency Inversion Principle means high-level modules should depend on concrete low-level classes.

Q24. The Facade pattern provides a simplified, unified interface to a complex subsystem.

Q25. Following DRY sometimes conflicts with KISS when over-abstracting to remove tiny duplications.

Q26. The Observer pattern establishes a one-to-many dependency so dependents are notified automatically of state changes.

Q27. Separation of Concerns and Single Responsibility Principle are completely unrelated ideas.

Q28. The Strategy pattern hard-codes one algorithm inside the client, making it impossible to swap behaviours.

Answer keyMark scheme & solutions

Section A (1 mark each)

Q1 → b. DRY targets duplication of knowledge/logic; a single authoritative representation. (Not perf/memory.) Q2 → b. KISS = choose the simplest working solution; complexity is a cost. Q3 → b. YAGNI = don't build for speculative future requirements. Q4 → b. SRP: one class = one reason to change. Q5 → b. Classic OCP definition (Meyer/Martin). Q6 → a. Substitutability of subtypes = Liskov. Q7 → b. ISP: no forced dependency on unused interface members. Q8 → c. Singleton is Creational (controls object creation/instances). Q9 → b. State pattern; behaviour changes with internal state. (Strategy is chosen externally, not state-driven.) Q10 → b. Adapter reconciles incompatible interfaces.

Section B (1 mark each)

Q Pattern Category
Q11 Factory Method A (Creational)
Q12 Decorator B (Structural)
Q13 Observer C (Behavioral)
Q14 Proxy B (Structural)
Q15 Builder A (Creational)
Q16 Strategy C (Behavioral)
Q17 Facade B (Structural)
Q18 Prototype A (Creational)
Q19 Command C (Behavioral)
Q20 Composite B (Structural)
Q21 Template Method C (Behavioral)
Q22 Abstract Factory A (Creational)

Count: Creational = Q11,15,18,22 (4); Structural = Q12,14,17,20 (4); Behavioral = Q13,16,19,21 (4).

Section C (1 mark T/F + 2 marks justification)

Q23 — False. DIP states high-level modules and low-level modules should both depend on abstractions, not concretions. (1+2)

Q24 — True. Facade wraps a complex subsystem behind one simple entry point, reducing client coupling. (1+2)

Q25 — True. Excessive DRY-driven abstraction can introduce indirection/complexity, contradicting KISS; balance is needed. (1+2)

Q26 — True. Observer defines a one-to-many relationship where subject state changes auto-notify subscribers. (1+2)

Q27 — False. They are closely related; SoC at module level and SRP at class level both push single, focused responsibilities. (1+2)

Q28 — False. Strategy encapsulates interchangeable algorithms behind a common interface, enabling runtime swapping — the opposite of hard-coding. (1+2)


Mark totals

Section A: 10 · Section B: 12 · Section C: 18 · Total = 40

[
  {"claim":"Section A has 10 one-mark questions totalling 10 marks","code":"secA=10*1\nresult=(secA==10)"},
  {"claim":"Section B has 12 matches (Q11-Q22) totalling 12 marks","code":"qs=list(range(11,23))\nresult=(len(qs)==12 and sum(1 for _ in qs)==12)"},
  {"claim":"Section B splits evenly 4/4/4 across the three categories","code":"creational={11,15,18,22}\nstructural={12,14,17,20}\nbehavioral={13,16,19,21}\nresult=(len(creational)==4 and len(structural)==4 and len(behavioral)==4 and len(creational|structural|behavioral)==12)"},
  {"claim":"Section C is 6 questions at 3 marks = 18, and grand total is 40","code":"secC=6*3\ntotal=10+12+secC\nresult=(secC==18 and total==40)"}
]