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

Study methods

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

Design Patterns Introduction

  • 45Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Design Patterns Overview
Design patterns are essentially ways of solving
problems in similar ways.

45 questions

  1. 1
    Design patterns are essentially ways of solving
    _____
    problems in similar ways.
    Hint

    Think about the core idea of reusing solutions.

    Answer

    similar

  2. 2
    The benefits of using design patterns include scalability, testability, separation of concerns, standard
    _____
    , and best practices.
    Hint

    This helps developers communicate effectively about their solutions.

    Answer

    terminology

  3. 3
    The
    _____
    are the four authors of the foundational book on design patterns.
    Hint

    They are often referred to as a group of software architects.

    Answer

    Gang of Four

  4. 4
    Creational design patterns relate to how you create specific
    _____
    .
    Hint

    They deal with object creation mechanisms.

    Answer

    objects

  5. 5
    Structural design patterns deal with how to structure the overall
    _____
    .
    Hint

    They focus on class and object composition.

    Answer

    project

  6. 6
    Behavioral design patterns relate to how components
    _____
    in the application.
    Hint

    They describe communication between objects.

    Answer

    interact

  7. 7
    The Singleton pattern provides a single
    _____
    for a resource.
    Hint

    It ensures a class has only one object.

    Answer

    instance

  8. 8
    A disadvantage of the Singleton is that it breaks the
    _____
    principle.
    Hint

    This principle means a class should have only one reason to change.

    Answer

    single responsibility

  9. 9
    In a multi-threaded environment, a naive Singleton implementation can be fixed by using a
    _____
    .
    Hint

    This synchronization mechanism prevents multiple threads from simultaneously creating instances.

    Answer

    lock

  10. 10
    The Factory Method pattern separates the
    _____
    of an object from its utilization.
    Hint

    It decouples the client from the instantiation logic.

    Answer

    creation

  11. 11
    In the Factory Method pattern, the design logic and creation are hidden from the
    _____
    .
    Hint

    The client uses the object without knowing how it was created.

    Answer

    client

  12. 12
    Abstract Factory is one level of abstraction above Factory Method; it is a factory that creates
    _____
    .
    Hint

    Think of it as a meta-factory.

    Answer

    factories

  13. 13
    In the Abstract Factory example, the
    _____
    restaurant and American restaurant are concrete factories.
    Hint

    One of the two types of cuisine mentioned.

    Answer

    French

  14. 14
    The Builder pattern allows an object to be initialized in
    _____
    ways.
    Hint

    It provides flexibility in constructing complex objects.

    Answer

    different

  15. 15
    In Python, a simplified Builder can be implemented using
    _____
    parameters in the constructor.
    Hint

    These allow you to specify only the parameters you need.

    Answer

    named

  16. 16
    The Prototype pattern lets us copy existing objects without depending on their
    _____
    .
    Hint

    It relies on the object itself to provide copying.

    Answer

    class

  17. 17
    In Python, the copy module provides two functions: copy (shallow copy) and `
    _____
    ` (deep copy).
    Hint

    The function name suggests it copies nested objects recursively.

    Answer

    deepcopy

  18. 18
    The Adapter pattern converts one
    _____
    of a class into another that the client expects.
    Hint

    It bridges incompatible interfaces.

    Answer

    interface

  19. 19
    In the Adapter example, the DisplayDataAdapter inherits from both StoreDatabaseData and `
    _____
    `.
    Hint

    This is the third-party class being adapted.

    Answer

    DisplayData

  20. 20
    The Bridge pattern converts from
    _____
    to composition.
    Hint

    It replaces class inheritance with object composition.

    Answer

    inheritance

  21. 21
    In the Bridge example, the BasicRemote holds a reference to a
    _____
    object.
    Hint

    This is the implementor interface.

    Answer

    device

  22. 22
    The Composite pattern allows you to structure objects into
    _____
    and manipulate multiple objects as a single one.
    Hint

    This structure is hierarchical.

    Answer

    trees

  23. 23
    In the Composite example, the Composite class has a price property that returns the
    _____
    of all items.
    Hint

    It aggregates the prices of child components.

    Answer

    sum

  24. 24
    The Decorator pattern attaches new
    _____
    to an object without altering existing code.
    Hint

    It wraps the original object.

    Answer

    behavior

  25. 25
    In the Decorator example, the EnhancedCoffeeMachine wraps a `
    _____
    ` object and adds its own functionality.
    Hint

    This is the underlying object being decorated.

    Answer

    BasicCoffeeMachine

  26. 26
    The Facade pattern provides a simple
    _____
    to complex functionality.
    Hint

    It hides the complexity of the underlying system.

    Answer

    interface

  27. 27
    In the Facade example, the UserRepository is a
    _____
    that hides the ComplexSystemStore details.
    Hint

    This class provides a simplified API.

    Answer

    facade

  28. 28
    The Flyweight pattern reduces memory footprint by sharing
    _____
    parts among similar objects.
    Hint

    It separates intrinsic (shared) state from extrinsic (unique) state.

    Answer

    common

  29. 29
    In the Flyweight example, the FighterFactory stores only three
    _____
    instances, one for each rank.
    Hint

    These are the shared flyweight objects.

    Answer

    Fighter

  30. 30
    The Proxy pattern provides the same
    _____
    as the original object and manages its lifecycle.
    Hint

    The client cannot distinguish the proxy from the real object.

    Answer

    interface

  31. 31
    In the Proxy example, the ProxyImage caches the `
    _____
    ` and only loads it from disk once.
    Hint

    This is the actual image object behind the proxy.

    Answer

    RealImage

  32. 32
    The Chain of Responsibility pattern defines a chain of
    _____
    to process a request.
    Hint

    Each can either process or pass the request along.

    Answer

    handlers

  33. 33
    In the Chain of Responsibility example, the AuthenticationHeader adds an authorization header and calls `
    _____
    ` to pass the request to the next handler.
    Hint

    This method moves the request down the chain.

    Answer

    do_next

  34. 34
    The Command pattern wraps a request in an
    _____
    that contains all required information.
    Hint

    This allows parameterization of clients with different requests.

    Answer

    object

  35. 35
    In the Command example, the CommandProcessor has a queue of commands and calls `
    _____
    ` on each when processing.
    Hint

    This is the method that performs the command's action.

    Answer

    execute

  36. 36
    The Interpreter pattern recursively evaluates
    _____
    and expressions in a language.
    Hint

    It defines a representation for the language's grammar.

    Answer

    grammar

  37. 37
    In the Interpreter example, terminal expressions represent
    _____
    and non-terminal expressions represent operators.
    Hint

    These are the leaf nodes in the abstract syntax tree.

    Answer

    numbers

  38. 38
    The Iterator pattern provides a way to traverse a
    _____
    without exposing its underlying representation.
    Hint

    It allows sequential access to elements.

    Answer

    collection

  39. 39
    The Mediator pattern provides a central object for
    _____
    between objects.
    Hint

    It reduces dependencies between components.

    Answer

    communication

  40. 40
    The Memento pattern saves and restores previous
    _____
    without revealing implementation details.
    Hint

    It implements undo/redo functionality.

    Answer

    state

  41. 41
    In the Memento pattern, the
    _____
    creates the memento, and the caretaker saves and restores them.
    Hint

    This is the object whose state is being saved.

    Answer

    originator

  42. 42
    The Observer pattern defines a subscription mechanism where objects (observers) are notified when a subject changes
    _____
    .
    Hint

    They are registered to receive updates.

    Answer

    state

  43. 43
    In the Observer example, the EventManager maintains a list of
    _____
    for each event type.
    Hint

    These are the observers that get notified.

    Answer

    listeners

  44. 44
    The State pattern allows an object to change its behavior based on its internal
    _____
    .
    Hint

    It looks like the object changes its class.

    Answer

    state

  45. 45
    In the State example, the game can be in states: welcome screen, playing, break, and
    _____
    .
    Hint

    This is the final state after the game finishes.

    Answer

    end game

1 of 45
Question 1 of 45

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent