1. Home
  2. Explore
  3. Computer Science
  4. Design Patterns in Python

Study methods

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

Design Patterns in Python

  • 10Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Strategy Pattern
The
design pattern allows you to replace one algorithm with another without the system that uses the algorithm knowing about it.

10 questions

  1. 1
    The
    _____
    design pattern allows you to replace one algorithm with another without the system that uses the algorithm knowing about it.
    Hint

    Think of a pattern that involves interchangeable families of algorithms.

    Answer

    strategy

  2. 2
    In the functional version of the strategy pattern, the key technique is
    _____
    to another function.
    Hint

    This technique is common in functional programming and helps replace class-based abstraction.

    Answer

    passing a function as an argument

  3. 3
    The
    _____
    design pattern decouples objects that change from objects that need to be notified of those changes.
    Hint

    This pattern is often used in event handling systems where multiple listeners need updates.

    Answer

    observer

  4. 4
    In the functional version of the observer pattern, observers are represented as a
    _____
    passed to the notify function.
    Hint

    Instead of a list of objects, you use a data structure of callables.

    Answer

    list of functions

  5. 5
    The
    _____
    design pattern defines a standard algorithm while allowing specific steps to be overridden by subclasses or passed-in functions.
    Hint

    It provides a skeleton of an algorithm with some parts left for customization.

    Answer

    template method

  6. 6
    In the functional version of the template method, hooks are represented as
    _____
    that can be optionally supplied.
    Hint

    These are the parts that can be overridden, just like methods in the class version.

    Answer

    functions

  7. 7
    The technique of returning a function from another function is used to create a closure that remembers the supplied operations, allowing the template method to be called later with only the
    _____
    .
    Hint

    This separates the fixed operations from the overridable parts for cleaner usage.

    Answer

    hooks

  8. 8
    The
    _____
    function from the functools module can simplify the functional template method by pre-applying some arguments.
    Hint

    It creates a new function with some arguments already fixed.

    Answer

    partial

  9. 9
    According to the content, the true value of design patterns is not their specific implementation but the
    _____
    they represent.
    Hint

    Design patterns categorize common recurring problems in software design.

    Answer

    problem categories

  10. 10
    The speaker learned design patterns from a course that used the programming language
    _____
    .
    Hint

    The course was new at the time and taught using an object-oriented language.

    Answer

    C++

1 of 10
Question 1 of 10

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent