1. Home
  2. Explore
  3. Computer Science
  4. Design Patterns Review

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Design Patterns Review

  • 59Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Pattern Foundations

Who initiated the pattern movement by applying the idea of patterns to architecture?

59 questions

  1. 1

    Who initiated the pattern movement by applying the idea of patterns to architecture?

    1. A

      Douglas Schmidt

    2. B

      Erich Gamma

    3. C

      Ralph Johnson

    4. D

      Christopher Alexander

    Correct answer
    D

    Christopher Alexander

    Explanation

    Christopher Alexander initiated the pattern movement in architecture and established many of the foundational ideas later applied to software.

  2. 2

    Which book by Christopher Alexander established the foundation for the pattern movement?

    1. A

      A Pattern Language

    2. B

      Pattern-Oriented Software Architecture

    3. C

      The Timeless Way of Building

    4. D

      Design Patterns

    Correct answer
    A

    A Pattern Language

    Explanation

    Christopher Alexander established the foundation of the pattern movement through his book A Pattern Language.

  3. 3

    Which set of elements is essential when describing a design pattern?

    1. A

      Name, context, problem, forces, solution, and consequences

    2. B

      Class, method, variable, constructor, package, and test

    3. C

      Requirement, budget, schedule, team, customer, and release

    4. D

      Input, output, compiler, editor, library, and framework

    Correct answer
    A

    Name, context, problem, forces, solution, and consequences

    Explanation

    A design pattern description includes a name, context, problem, forces, solution, and consequences. Known uses are also commonly included.

  4. 4

    Why are the consequences of a design pattern important?

    1. A

      They identify the programming language in which the pattern was invented

    2. B

      They describe the benefits and liabilities of applying the pattern

    3. C

      They provide the exact source code required to implement the pattern

    4. D

      They guarantee that the pattern will improve every possible design

    Correct answer
    B

    They describe the benefits and liabilities of applying the pattern

    Explanation

    Consequences explain the benefits, drawbacks, limitations, and trade-offs that result from applying a pattern.

  5. 5

    What distinguishes a design pattern from a one-time solution?

    1. A

      A design pattern is a proven solution to a recurring problem

    2. B

      A design pattern is always implemented as a single reusable class

    3. C

      A design pattern is a complete application that can be copied unchanged

    4. D

      A design pattern is valid only when it uses object-oriented inheritance

    Correct answer
    A

    A design pattern is a proven solution to a recurring problem

    Explanation

    A design pattern is a proven solution idea or template for a problem that recurs across projects. It is not necessarily a concrete implementation.

  6. 6

    Why must the context of a design pattern be identified?

    1. A

      The same pattern may be appropriate in one domain but inappropriate in another

    2. B

      The context determines which compiler will translate the pattern

    3. C

      The context specifies the exact number of classes required by the pattern

    4. D

      The context eliminates the need to describe the pattern's consequences

    Correct answer
    A

    The same pattern may be appropriate in one domain but inappropriate in another

    Explanation

    Patterns apply within particular contexts. A pattern from software development, for example, cannot automatically be transferred to an unrelated domain.

  7. 7

    What makes a problem especially suitable for a design pattern?

    1. A

      It occurs only once in a particular application

    2. B

      It can be solved immediately by writing a single statement

    3. C

      It has exactly one obvious solution with no competing concerns

    4. D

      It involves conflicting forces or constraints that require a trade-off

    Correct answer
    D

    It involves conflicting forces or constraints that require a trade-off

    Explanation

    Pattern-worthy problems are generally nontrivial and involve antagonistic or conflicting forces, such as limited memory, processing power, or energy.

  8. 8

    Why are known uses valuable in a pattern description?

    1. A

      They prove that the pattern has no disadvantages in practice

    2. B

      They specify the only programming language in which the pattern works

    3. C

      They show that the pattern has been applied successfully in real systems

    4. D

      They replace the need to explain the pattern's problem and solution

    Correct answer
    C

    They show that the pattern has been applied successfully in real systems

    Explanation

    Known uses provide real-world examples and demonstrate that the solution has been applied repeatedly and successfully.

  9. 9

    What is the primary purpose of wrapping patterns such as Adapter, Proxy, Decorator, and Facade?

    1. A

      To place an additional abstraction layer around an existing component

    2. B

      To represent every object in a system as a state machine

    3. C

      To ensure that exactly one object exists in the entire application

    4. D

      To divide a system into model, view, and controller responsibilities

    Correct answer
    A

    To place an additional abstraction layer around an existing component

    Explanation

    Wrapping patterns add a layer around another component or abstraction to alter access, behavior, interface, or complexity.

  10. 10

    What is the main purpose of creational design patterns?

    1. A

      To divide an application into architectural layers

    2. B

      To coordinate communication among distributed components

    3. C

      To synchronize concurrent threads

    4. D

      To manage or simplify the creation of objects

    Correct answer
    D

    To manage or simplify the creation of objects

    Explanation

    Creational patterns focus on object creation, especially when the creation process is complex, configurable, or controlled.

  11. 11

    Which pattern is especially associated with constructing an object through multiple steps?

    1. A

      Builder

    2. B

      Observer

    3. C

      Iterator

    4. D

      Mediator

    Correct answer
    A

    Builder

    Explanation

    The Builder pattern constructs an object through multiple explicit steps, which is useful when creation is complex.

  12. 12

    What is the central idea of the Prototype pattern?

    1. A

      Create new objects by using an existing object as a template

    2. B

      Send a request through a chain of possible handlers

    3. C

      Create only one instance of a class for the entire application

    4. D

      Separate a system into independent presentation layers

    Correct answer
    A

    Create new objects by using an existing object as a template

    Explanation

    Prototype uses an existing object as a template from which new objects can be created, potentially at runtime.

  13. 13

    What does the Singleton pattern guarantee?

    1. A

      That a class has only one instance

    2. B

      That every object has multiple interchangeable implementations

    3. C

      That every request is handled by a different object

    4. D

      That all objects are created through several construction steps

    Correct answer
    A

    That a class has only one instance

    Explanation

    The Singleton pattern restricts a class to a single instance and takes responsibility for ensuring that it is created only once.

  14. 14

    What is the main purpose of behavioral design patterns?

    1. A

      To guarantee that objects are created without constructors

    2. B

      To specify the memory layout of every class

    3. C

      To determine how hardware resources are physically manufactured

    4. D

      To define or modify how objects behave and interact

    Correct answer
    D

    To define or modify how objects behave and interact

    Explanation

    Behavioral patterns address object behavior, communication, algorithms, state changes, and the distribution of responsibilities.

  15. 15

    Which pattern allows an algorithm to be represented abstractly and exchanged at runtime?

    1. A

      Strategy

    2. B

      Singleton

    3. C

      Facade

    4. D

      Composite

    Correct answer
    A

    Strategy

    Explanation

    Strategy encapsulates an algorithm behind an abstraction, allowing different algorithms to be selected or exchanged, including at runtime.

  16. 16

    What does the Command pattern encapsulate?

    1. A

      A collection's internal data structure in an iterator

    2. B

      A state machine's transitions in a concrete subclass

    3. C

      A complete application's architecture in a single class

    4. D

      A method call and its environment in an object

    Correct answer
    D

    A method call and its environment in an object

    Explanation

    Command encapsulates a request or method call as an object, allowing it to be stored, passed, invoked later, or undone.

  17. 17

    When is the State pattern most appropriate?

    1. A

      When several construction steps must be hidden from a client

    2. B

      When a system must expose only one global instance

    3. C

      When an object's behavior should change according to its current state

    4. D

      When an object must be converted into an incompatible interface

    Correct answer
    C

    When an object's behavior should change according to its current state

    Explanation

    State models an object as a state machine whose actions and reactions vary depending on the object's current state.

  18. 18

    Which group contains architectural patterns mentioned in the content?

    1. A

      Adapter, Proxy, Decorator, Facade, and Prototype

    2. B

      Layers, Broker, Master-Slave, Client-Server, and Pipes and Filters

    3. C

      Builder, Singleton, Composite, Interpreter, and Observer

    4. D

      Strategy, Command, State, Iterator, and Memento

    Correct answer
    B

    Layers, Broker, Master-Slave, Client-Server, and Pipes and Filters

    Explanation

    Architectural patterns influence the overall structure of an application. Examples include Layers, Broker, Master-Slave, Client-Server, and Pipes and Filters.

  19. 19

    What is the defining purpose of an Iterator?

    1. A

      To notify every dependent object about a state change

    2. B

      To create a single instance that is shared by all clients

    3. C

      To traverse elements of a collection without exposing its internal representation

    4. D

      To convert one interface into another compatible interface

    Correct answer
    C

    To traverse elements of a collection without exposing its internal representation

    Explanation

    Iterator provides a way to access collection elements sequentially while hiding how the collection is internally implemented.

  20. 20

    How do communication patterns generally affect system design?

    1. A

      They ensure that all objects directly call every other object

    2. B

      They organize information exchange and can decouple senders from receivers

    3. C

      They eliminate the need for messages between distributed components

    4. D

      They focus exclusively on reducing the number of object constructors

    Correct answer
    B

    They organize information exchange and can decouple senders from receivers

    Explanation

    Communication patterns manage how objects exchange information, often by decoupling senders and receivers or encapsulating data in messages.

  21. 21

    What is the primary concern of concurrency patterns?

    1. A

      Selecting a single algorithm from a family of interchangeable algorithms

    2. B

      Defining the visual presentation of an application's user interface

    3. C

      Creating objects from reusable templates at runtime

    4. D

      Managing synchronization, parallel activity, and coordination among concurrent operations

    Correct answer
    D

    Managing synchronization, parallel activity, and coordination among concurrent operations

    Explanation

    Concurrency patterns address issues involving locks, monitors, active objects, futures, and asynchronous execution.

  22. 22

    What problem do resource patterns primarily address?

    1. A

      Choosing between alternative user-interface layouts

    2. B

      Acquiring resources correctly and avoiding forgotten releases

    3. C

      Representing a request as an executable object

    4. D

      Converting incompatible object interfaces

    Correct answer
    B

    Acquiring resources correctly and avoiding forgotten releases

    Explanation

    Resource patterns concern when resources should be acquired and how their release can be reliably managed.

  23. 23

    How does reference counting help manage an object?

    1. A

      It creates a new object whenever a reference is added

    2. B

      It restricts the object to one reference throughout its lifetime

    3. C

      It guarantees that the object can never be deleted

    4. D

      It keeps the object in memory until no references to it remain

    Correct answer
    D

    It keeps the object in memory until no references to it remain

    Explanation

    Reference counting tracks how many references point to an object and deletes the object when nobody needs it anymore.

  24. 24

    What is the relationship between the Interpreter pattern and an abstract syntax tree?

    1. A

      An abstract syntax tree provides synchronization for concurrent interpreters

    2. B

      An abstract syntax tree can represent the structure interpreted by the pattern

    3. C

      An abstract syntax tree converts a network message into a resource lease

    4. D

      An abstract syntax tree guarantees that only one interpreter instance exists

    Correct answer
    B

    An abstract syntax tree can represent the structure interpreted by the pattern

    Explanation

    The Interpreter pattern and abstract syntax trees are closely related because an abstract syntax tree represents the structure of expressions to be interpreted.

  25. 25

    Which part of a pattern description explains when the pattern should be used?

    1. A

      The known uses

    2. B

      The class hierarchy

    3. C

      The implementation code

    4. D

      The context

    Correct answer
    D

    The context

    Explanation

    The context identifies the situation or domain in which the pattern applies and helps determine whether it is appropriate.

  26. 26

    What should the static part of a pattern solution describe?

    1. A

      The performance measurements from all known uses

    2. B

      The historical origin of the pattern movement

    3. C

      The timing of every runtime method call

    4. D

      The participating classes and objects

    Correct answer
    D

    The participating classes and objects

    Explanation

    The static part describes the classes and objects that participate in the solution and their structural relationships.

  27. 27

    What should the dynamic part of a pattern solution describe?

    1. A

      How many projects have used the pattern

    2. B

      How the pattern is categorized in a textbook

    3. C

      How the pattern's name was selected

    4. D

      How participants interact during runtime

    Correct answer
    D

    How participants interact during runtime

    Explanation

    The dynamic part explains runtime behavior, including object construction, communication, and which participant calls another.

  28. 28

    Why are forces included in a pattern description?

    1. A

      They list all the methods that must appear in every participating class

    2. B

      They identify which compiler optimization should be enabled

    3. C

      They prove that the solution is independent of all requirements

    4. D

      They explain the constraints and competing concerns that make the problem difficult

    Correct answer
    D

    They explain the constraints and competing concerns that make the problem difficult

    Explanation

    Forces represent constraints and competing requirements, such as limited memory, CPU capacity, energy, flexibility, or communication overhead.

  29. 29

    Which statement best describes a pattern solution?

    1. A

      It is a generic description of how the problem can be addressed

    2. B

      It is a complete implementation that must be copied exactly

    3. C

      It is a guarantee that all trade-offs have been eliminated

    4. D

      It is a list of unrelated programming techniques

    Correct answer
    A

    It is a generic description of how the problem can be addressed

    Explanation

    A pattern provides a general solution idea rather than a fixed implementation. Developers adapt it to their particular context.

  30. 30

    A broker improves communication flexibility but introduces additional communication overhead. What does this example illustrate?

    1. A

      A design pattern eliminates all runtime costs

    2. B

      A design pattern can be used without considering its context

    3. C

      A design pattern has both benefits and liabilities

    4. D

      A design pattern is equivalent to a language-specific idiom

    Correct answer
    C

    A design pattern has both benefits and liabilities

    Explanation

    Patterns involve trade-offs. A Broker can provide useful decoupling and flexibility while also adding overhead and deployment complexity.

  31. 31

    Why could using the Observer pattern synchronously with millions of observers cause a problem?

    1. A

      A single change may require informing an extremely large number of objects

    2. B

      The pattern automatically removes every observer after one notification

    3. C

      Observers prevent all objects from communicating with one another

    4. D

      Observers can operate only when exactly one object exists

    Correct answer
    A

    A single change may require informing an extremely large number of objects

    Explanation

    If a change is propagated synchronously to millions of observers, the large number of notifications can make the application very slow.

  32. 32

    Why are consequences useful when evaluating competing patterns for a design?

    1. A

      They ensure that the pattern with the most classes is always selected

    2. B

      They allow developers to compare trade-offs against the requirements

    3. C

      They show that all patterns are equally appropriate

    4. D

      They remove the need to understand the original problem

    Correct answer
    B

    They allow developers to compare trade-offs against the requirements

    Explanation

    Consequences support design decisions by showing how each pattern addresses forces and what benefits or liabilities it introduces.

  33. 33

    What does the Single Responsibility Principle state?

    1. A

      A class should contain every operation used by its clients

    2. B

      A class should depend directly on all concrete implementations

    3. C

      A class should have one responsibility and one reason to change

    4. D

      A class should never be extended after it is compiled

    Correct answer
    C

    A class should have one responsibility and one reason to change

    Explanation

    The Single Responsibility Principle states that a class should have only one responsibility and therefore one reason to change.

  34. 34

    What does the Open-Closed Principle require?

    1. A

      Software entities should be open for extension but closed for modification

    2. B

      Software entities should expose every implementation detail to clients

    3. C

      Software entities should be rewritten whenever new behavior is needed

    4. D

      Software entities should be closed to extension and open to modification

    Correct answer
    A

    Software entities should be open for extension but closed for modification

    Explanation

    The Open-Closed Principle favors extending behavior without modifying the existing source code.

  35. 35

    How can Strategy or State help satisfy the Open-Closed Principle?

    1. A

      They allow behavior to change through supplied implementations or configurations

    2. B

      They require the original class to be rewritten for every new behavior

    3. C

      They eliminate all abstractions from the design

    4. D

      They ensure that behavior is fixed permanently at compile time

    Correct answer
    A

    They allow behavior to change through supplied implementations or configurations

    Explanation

    Strategy and State can allow behavior to vary through interchangeable strategies or state configurations while leaving the core class unchanged.

  36. 36

    What is the Liskov Substitution Principle concerned with?

    1. A

      Substituting derived objects for their base types without violating expected behavior

    2. B

      Encapsulating a method call inside a command object

    3. C

      Restricting each class to a single instance

    4. D

      Separating an application into layers of presentation

    Correct answer
    A

    Substituting derived objects for their base types without violating expected behavior

    Explanation

    The Liskov Substitution Principle requires that objects of derived classes be usable wherever their base class is expected.

  37. 37

    What does the Interface Segregation Principle recommend?

    1. A

      Clients should depend directly on concrete classes rather than abstractions

    2. B

      Clients should be prevented from using any interface more than once

    3. C

      Clients should receive one large interface containing every possible operation

    4. D

      Clients should depend on fine-grained interfaces tailored to their needs

    Correct answer
    D

    Clients should depend on fine-grained interfaces tailored to their needs

    Explanation

    Interface Segregation favors small, client-specific interfaces instead of forcing clients to depend on methods they do not need.

  38. 38

    What does the phrase “easy to use right and hard to use wrong” imply about interfaces?

    1. A

      An interface should make correct use intuitive and misuse difficult

    2. B

      An interface should expose every internal detail to maximize flexibility

    3. C

      An interface should provide as many unrelated operations as possible

    4. D

      An interface should require clients to understand implementation mechanisms

    Correct answer
    A

    An interface should make correct use intuitive and misuse difficult

    Explanation

    Good interfaces guide users toward correct behavior, match expectations, and make common mistakes difficult.

  39. 39

    What is the main idea of Dependency Inversion?

    1. A

      High-level code should depend on abstractions rather than concrete classes

    2. B

      All dependencies should be placed in one large implementation class

    3. C

      High-level code should instantiate every concrete dependency directly

    4. D

      Concrete classes should depend on no interfaces or abstract classes

    Correct answer
    A

    High-level code should depend on abstractions rather than concrete classes

    Explanation

    Dependency Inversion encourages programming against abstractions such as interfaces or abstract classes, allowing implementations to vary.

  40. 40

    How does programming against abstractions improve extensibility?

    1. A

      The design no longer needs defined interfaces

    2. B

      Concrete classes become impossible to replace after compilation

    3. C

      New implementations can be supplied without changing the client code

    4. D

      All clients must be rewritten whenever a new implementation is introduced

    Correct answer
    C

    New implementations can be supplied without changing the client code

    Explanation

    When clients depend on abstractions, developers can provide new derived classes or implementations without changing the clients.

  41. 41

    What does decomposition accomplish when solving a large problem?

    1. A

      It combines unrelated problems into one larger implementation unit

    2. B

      It guarantees that the final solution will require no testing

    3. C

      It breaks the problem into smaller tasks that can be solved step by step

    4. D

      It hides all requirements so that no design decisions are necessary

    Correct answer
    C

    It breaks the problem into smaller tasks that can be solved step by step

    Explanation

    Decomposition divides a large, difficult problem into smaller parts, making it possible to address those parts incrementally.

  42. 42

    What is the purpose of abstraction in software design?

    1. A

      To eliminate the need for any communication between objects

    2. B

      To hide unnecessary details behind a simpler interface

    3. C

      To force clients to understand network and hardware protocols

    4. D

      To expose every implementation detail to every client

    Correct answer
    B

    To hide unnecessary details behind a simpler interface

    Explanation

    Abstraction reduces complexity by hiding details and presenting clients with a simpler way to use a component.

  43. 43

    An application developer sends a network message without knowing the format of the underlying MAC frame or IP header. Which principle is illustrated?

    1. A

      Interface inheritance

    2. B

      Singleton creation

    3. C

      Reference counting

    4. D

      Abstraction

    Correct answer
    D

    Abstraction

    Explanation

    The networking interface abstracts away lower-level frame and header details so the application developer can work with a simpler message-oriented interface.

  44. 44

    What does decoupling seek to reduce between software components?

    1. A

      The number of meaningful abstractions

    2. B

      The number of requirements in the system

    3. C

      The need for any runtime behavior

    4. D

      Direct dependencies between components

    Correct answer
    D

    Direct dependencies between components

    Explanation

    Decoupling reduces direct dependencies, allowing components to change independently and communicate through abstractions or runtime connections.

  45. 45

    How can decoupling shift design decisions to a later time?

    1. A

      Components must hard-code all communication partners during compilation

    2. B

      Components can select or connect to communication partners at runtime

    3. C

      Components must be placed in the same class before execution

    4. D

      Components must avoid all interfaces and abstractions

    Correct answer
    B

    Components can select or connect to communication partners at runtime

    Explanation

    Decoupled components need not know their exact partners in advance; the connections or implementations can be selected later, including at runtime.

  46. 46

    Why should developers avoid premature optimization?

    1. A

      It prevents developers from considering performance requirements at all

    2. B

      It always produces slower code than an unoptimized implementation

    3. C

      It guarantees that the system will use excessive memory

    4. D

      It can encourage unnecessary complexity before actual needs are known

    Correct answer
    D

    It can encourage unnecessary complexity before actual needs are known

    Explanation

    The content recommends implementing what is needed now while thinking reasonably ahead, rather than over-engineering based on speculative requirements.

  47. 47

    Why should developers follow the conventions of the language or environment in which they work?

    1. A

      Conventions make code more intuitive and understandable to other developers

    2. B

      Conventions prevent a program from running in any other environment

    3. C

      Conventions guarantee that every implementation uses identical algorithms

    4. D

      Conventions eliminate the need for abstractions and design patterns

    Correct answer
    A

    Conventions make code more intuitive and understandable to other developers

    Explanation

    Following established coding styles and environmental conventions helps others read, understand, and use the software correctly.

  48. 48

    What is the risk of applying many design patterns to a simple script or Hello World application?

    1. A

      The application will automatically violate the Singleton pattern

    2. B

      The patterns will guarantee that the application has no behavior

    3. C

      The solution may become unnecessarily complex and over-engineered

    4. D

      The script will be unable to use any programming language

    Correct answer
    C

    The solution may become unnecessarily complex and over-engineered

    Explanation

    Patterns should address real recurring problems. Applying them to trivial software can add complexity without providing meaningful benefits.

  49. 49

    What is the difference between a classical design pattern and an idiom?

    1. A

      A classical pattern is a complete application, while an idiom is a hardware configuration

    2. B

      A classical pattern affects several components, while an idiom is usually language-specific and smaller

    3. C

      A classical pattern is always language-specific, while an idiom affects an entire architecture

    4. D

      A classical pattern has no known uses, while an idiom must be used across many domains

    Correct answer
    B

    A classical pattern affects several components, while an idiom is usually language-specific and smaller

    Explanation

    Classical design patterns generally address problems involving several components. Idioms solve smaller, often language-specific problems.

  50. 50

    Which example is a language-specific idiom mentioned in the content?

    1. A

      The Python construct if __name__ == "__main__"

    2. B

      The Broker pattern for distributed communication

    3. C

      The Layers architecture used across multiple systems

    4. D

      The Model-View-Controller architectural structure

    Correct answer
    A

    The Python construct if __name__ == "__main__"

    Explanation

    The if __name__ == "__main__" construct is a Python-specific idiom rather than a language-independent design pattern.

  51. 51

    Why are architectural patterns distinguished from classical design patterns?

    1. A

      Architectural patterns cannot involve communication among components

    2. B

      Architectural patterns apply only to object construction

    3. C

      Architectural patterns solve only one-line implementation problems

    4. D

      Architectural patterns influence the structure of the whole application

    Correct answer
    D

    Architectural patterns influence the structure of the whole application

    Explanation

    Architectural patterns, such as Layers and Broker, influence the overall architecture and organization of an application.

  52. 52

    Which statement best describes the language independence expected of software design patterns?

    1. A

      The pattern must be provided as a library by the language vendor

    2. B

      The pattern is valid only when implemented with inheritance

    3. C

      The design idea should generally apply regardless of the programming language

    4. D

      The pattern must use the syntax of exactly one programming language

    Correct answer
    C

    The design idea should generally apply regardless of the programming language

    Explanation

    Software design patterns describe language-independent design ideas. Language-specific solutions are more appropriately considered idioms.

  53. 53

    Why should a developer evaluate whether to use Broker in a particular application rather than using it everywhere?

    1. A

      Broker is guaranteed to reduce communication overhead in every system

    2. B

      Broker introduces trade-offs and is beneficial only in suitable contexts

    3. C

      Broker can be used only for creating objects at compile time

    4. D

      Broker eliminates all deployment and registration concerns

    Correct answer
    B

    Broker introduces trade-offs and is beneficial only in suitable contexts

    Explanation

    Broker can provide flexible communication but may introduce communication overhead, registration requirements, and deployment complexity.

  54. 54

    A system must run on a device with very limited memory, CPU capacity, and energy. How should these factors influence pattern selection?

    1. A

      They should be treated as forces that constrain the feasible solution

    2. B

      They should be handled only after the software has been deployed

    3. C

      They should lead automatically to choosing the most complex pattern

    4. D

      They should be ignored because patterns always have the same cost

    Correct answer
    A

    They should be treated as forces that constrain the feasible solution

    Explanation

    Limited memory, CPU resources, and energy are examples of forces that shape design decisions and may make some pattern solutions unsuitable.

  55. 55

    What is the most appropriate way to choose between Mediator and Observer for a particular use case?

    1. A

      Always choose Observer because it is a behavioral pattern

    2. B

      Always choose Mediator because it reduces every dependency

    3. C

      Choose whichever pattern has the shorter name

    4. D

      Compare their consequences with the requirements and communication needs

    Correct answer
    D

    Compare their consequences with the requirements and communication needs

    Explanation

    Pattern selection should be based on the problem, forces, requirements, and consequences of each possible solution.

  56. 56

    What practical benefit comes from knowing the names and basic ideas of common patterns?

    1. A

      Developers can avoid documenting all architectural decisions

    2. B

      Developers can apply every pattern without understanding its consequences

    3. C

      Developers no longer need to analyze requirements or constraints

    4. D

      Developers can communicate design ideas efficiently with one another

    Correct answer
    D

    Developers can communicate design ideas efficiently with one another

    Explanation

    Shared pattern names provide a concise vocabulary for discussing possible solutions with other developers and students.

  57. 57

    What is the central purpose of patterns as a way of expressing knowledge?

    1. A

      To make all software solutions identical across projects

    2. B

      To make knowledge explicit, findable, understandable, and applicable

    3. C

      To replace practical application with theoretical classification

    4. D

      To preserve knowledge only as memorized definitions

    Correct answer
    B

    To make knowledge explicit, findable, understandable, and applicable

    Explanation

    Patterns document knowledge, make it available through publications and other media, organize it understandably, and show how it can be applied in real situations.

  58. 58

    Why does repeated application help establish a pattern?

    1. A

      Repeated use removes the need to identify the original problem

    2. B

      Repeated use converts the pattern into a programming language

    3. C

      Repeated use guarantees that the pattern has no drawbacks

    4. D

      Repeated use provides evidence that the solution works across multiple situations

    Correct answer
    D

    Repeated use provides evidence that the solution works across multiple situations

    Explanation

    A solution becomes recognized as a pattern when it has been applied repeatedly and shown to work for a recurring problem.

  59. 59

    Which statement best captures the recommended way to learn design patterns?

    1. A

      Memorize pattern names without considering their use cases

    2. B

      Follow a prescribed implementation without adapting it to requirements

    3. C

      Apply every known pattern to every software project

    4. D

      Understand the idea and apply it to appropriate problems in one's own context

    Correct answer
    D

    Understand the idea and apply it to appropriate problems in one's own context

    Explanation

    Effective learning involves understanding patterns, considering their consequences, and applying them to relevant problems and personal project contexts.

Question 1 of 59
Question 1 of 59

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent