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

Study methods

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

Design Patterns Overview

  • 59Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Design Patterns Overview
Design patterns are well-tested, reusable solutions that are also
solutions.

59 questions

  1. 1
    Design patterns are well-tested, reusable solutions that are also
    _____
    solutions.
    Hint

    They have been optimized through many uses.

    Answer

    optimal

  2. 2
    Design patterns provide a common
    _____
    for developers to facilitate communication.
    Hint

    They help architects be on the same page.

    Answer

    vocabulary

  3. 3
    The three families of design patterns covered in this course are creational, structural, and
    _____
    .
    Hint

    This family deals with interaction and communication between objects.

    Answer

    behavioral

  4. 4
    Creational design patterns manage
    _____
    creation mechanisms.
    Hint

    They deal with how objects are instantiated.

    Answer

    object

  5. 5
    Structural design patterns improve and simplify designs by identifying efficient ways of composing
    _____
    among entities.
    Hint

    They focus on object composition and hierarchies.

    Answer

    relationships

  6. 6
    Behavioral design patterns improve
    _____
    and communication between objects.
    Hint

    They deal with how objects exchange messages.

    Answer

    interaction

  7. 7
    The Singleton pattern ensures a class has only one
    _____
    and provides global access to it.
    Hint

    It controls instantiation to a single object.

    Answer

    instance

  8. 8
    The Singleton pattern is an example of
    _____
    instantiation if the instance is created only when first needed.
    Hint

    Creation is deferred until the first request.

    Answer

    lazy

  9. 9
    The
    _____
    pattern provides a mechanism for creating objects without exposing the instantiation logic to the client.
    Hint

    It uses a method to create objects instead of constructors.

    Answer

    Factory Method

  10. 10
    In the Factory Method pattern, objects are created through an
    _____
    not a concretion.
    Hint

    The caller uses a common interface rather than concrete types.

    Answer

    abstraction

  11. 11
    The Builder pattern separates the construction of a complex object from its
    _____
    .
    Hint

    The construction process can create different representations.

    Answer

    representation

  12. 12
    In the Builder pattern, the
    _____
    coordinates the construction steps by delegating to a builder.
    Hint

    It manages the building process.

    Answer

    director

  13. 13
    The Adapter pattern converts the
    _____
    of a class into another interface that clients expect.
    Hint

    It makes incompatible interfaces work together.

    Answer

    interface

  14. 14
    The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them
    _____
    .
    Hint

    They can be swapped at runtime.

    Answer

    interchangeable

  15. 15
    In the Strategy pattern, the
    _____
    class aggregates a strategy interface.
    Hint

    It is the class that uses the strategy.

    Answer

    context

  16. 16
    The Observer pattern creates a one-to-many dependency so that when one object changes state, all its
    _____
    are notified.
    Hint

    They subscribe to updates.

    Answer

    dependents

  17. 17
    The State pattern allows an object to alter its behavior when its internal
    _____
    changes.
    Hint

    The object appears to change its class.

    Answer

    state

  18. 18
    In UML, class diagrams convey the
    _____
    of a design pattern.
    Hint

    They show classes and relationships.

    Answer

    structure

  19. 19
    Sequence diagrams illustrate the
    _____
    of objects over time.
    Hint

    They show method calls in order.

    Answer

    interaction

  20. 20
    A generalization relationship in UML represents
    _____
    .
    Hint

    It is an 'is-a' relationship.

    Answer

    inheritance

  21. 21
    An aggregation with a black diamond indicates that the whole
    _____
    its part.
    Hint

    The part cannot exist without the whole.

    Answer

    contains

  22. 22
    Loose coupling means weak knowledge
    _____
    between components.
    Hint

    Changes to one component affect few others.

    Answer

    association

  23. 23
    Separation of concerns breaks architecture into main tiers such as presentation, business, and
    _____
    .
    Hint

    It's also called resource access layer.

    Answer

    data access

  24. 24
    The Law of Demeter states that a unit should only talk to its
    _____
    .
    Hint

    It should not talk to strangers.

    Answer

    friends

  25. 25
    The Single Responsibility Principle states that there should never be more than one
    _____
    for a class to change.
    Hint

    Each class should have one central responsibility.

    Answer

    reason

  26. 26
    The Open-Closed Principle states that software entities should be open for extension but closed for
    _____
    .
    Hint

    You can add new behavior without changing existing code.

    Answer

    modification

  27. 27
    The Liskov Substitution Principle says that functions using base classes must be able to use objects of
    _____
    classes without knowing it.
    Hint

    Subtypes must be substitutable for their base types.

    Answer

    derived

  28. 28
    The Interface Segregation Principle states that clients should not be forced to depend upon
    _____
    they do not use.
    Hint

    Avoid fat interfaces.

    Answer

    interfaces

  29. 29
    The Dependency Inversion Principle states that one should depend upon
    _____
    not concretions.
    Hint

    High-level modules should not depend on low-level modules.

    Answer

    abstractions

  30. 30
    In Python, a class is a
    _____
    for creating objects.
    Hint

    It defines attributes and methods.

    Answer

    recipe

  31. 31
    The `
    _____
    ` method is the constructor in Python, responsible for initializing an object's attributes.
    Hint

    It is called automatically after object creation.

    Answer

    init

  32. 32
    Encapsulation in OOP means gathering relevant data and
    _____
    in one place.
    Hint

    It controls complexity and hides internal details.

    Answer

    functionality

  33. 33
    Inheritance allows a class to generalize by inheriting
    _____
    and behavior from a parent class.
    Hint

    It promotes code reuse.

    Answer

    data

  34. 34
    In Python, an abstract class is created by inheriting from `
    _____
    `.
    Hint

    It stands for Abstract Base Class.

    Answer

    ABC

  35. 35
    An interface in Python is an abstract class with only abstract methods and
    _____
    implementation.
    Hint

    It defines a contract without providing functionality.

    Answer

    no

  36. 36
    A metaclass in Python is a class that defines the behavior for creating
    _____
    .
    Hint

    It is a 'class of a class'.

    Answer

    classes

  37. 37
    The Singleton pattern can be implemented in Python using a
    _____
    class, which controls instantiation.
    Hint

    It overrides the __call__ method.

    Answer

    metaclass

  38. 38
    Thread safety in Singleton is achieved by using a
    _____
    to protect the critical section.
    Hint

    It serializes access to the instance creation.

    Answer

    lock

  39. 39
    In the classic Gang of Four Singleton, the constructor is made private or disabled by overriding `
    _____
    ` to throw an error.
    Hint

    It prevents external instantiation.

    Answer

    init

  40. 40
    The Factory Method pattern has two variants: the classic and the simple (parameterized) Factory method. The simple factory uses a
    _____
    method to create instances.
    Hint

    It is often implemented as a static method.

    Answer

    static

  41. 41
    In the Builder pattern, the concrete builder implements the building steps defined in the
    _____
    builder interface.
    Hint

    It provides concrete implementations for each step.

    Answer

    abstract

  42. 42
    The Adapter pattern can be used to convert data formats, such as from
    _____
    to JSON.
    Hint

    Example in course: investment data from XML to JSON.

    Answer

    XML

  43. 43
    The Strategy pattern is often used to avoid
    _____
    statements that switch between different variants of an algorithm.
    Hint

    It replaces complex conditionals with polymorphic objects.

    Answer

    conditional

  44. 44
    In the Observer pattern, the subject maintains a list of observers and notifies them of state changes by calling their
    _____
    method.
    Hint

    This method is defined in the observer interface.

    Answer

    update

  45. 45
    The State pattern is similar to the concept of
    _____
    machines.
    Hint

    It involves a finite number of states with discrete transitions.

    Answer

    finite state

  46. 46
    In Python, an abstract method is declared using the `
    _____
    ` decorator.
    Hint

    It forces subclasses to implement the method.

    Answer

    @abstractmethod

  47. 47
    The `
    _____
    ` method in a metaclass is responsible for controlling the creation of instances of the classes it creates.
    Hint

    It is invoked when a class instance is called.

    Answer

    call

  48. 48
    In the course, John Conway's Game of Life is used as a project to apply design patterns. The game is a
    _____
    player game.
    Hint

    Its evolution is determined solely by the initial state.

    Answer

    zero

  49. 49
    In the Game of Life, a live cell with two or three live neighbors
    _____
    .
    Hint

    It remains alive in the next generation.

    Answer

    survives

  50. 50
    A dead cell with exactly three live neighbors becomes a
    _____
    cell.
    Hint

    This represents birth.

    Answer

    live

  51. 51
    All other live cells (with fewer than 2 or more than 3 live neighbors)
    _____
    in the next generation.
    Hint

    They die from underpopulation or overpopulation.

    Answer

    die

  52. 52
    UML diagrams used in the course are class diagrams and
    _____
    diagrams.
    Hint

    They show interactions over time.

    Answer

    sequence

  53. 53
    In UML, a dependency is shown as a dashed arrow and indicates that one class
    _____
    another.
    Hint

    It is a weaker relationship than association.

    Answer

    uses

  54. 54
    In the context of the Adapter pattern, the
    _____
    is the existing class that needs to be adapted.
    Hint

    It has an incompatible interface.

    Answer

    adaptee

  55. 55
    The
    _____
    pattern is described as the 'crowning jewel' of Gang of Four design patterns.
    Hint

    It allows algorithms to vary independently.

    Answer

    Strategy

  56. 56
    The Observer pattern is key to reactive behavior and is a core part of the
    _____
    architectural pattern.
    Hint

    It's used in many UI frameworks.

    Answer

    MVC

  57. 57
    In the State pattern, each concrete state is often implemented as a
    _____
    because it has no internal state of its own.
    Hint

    They are shared across contexts.

    Answer

    Singleton

  58. 58
    The
    _____
    principle in SOLID states that you should depend on abstractions, not concretions.
    Hint

    The 'D' in SOLID.

    Answer

    Dependency Inversion

  59. 59
    The
    _____
    pattern provides the exact same interface to the wrapped object (as opposed to Adapter which changes the interface).
    Hint

    It controls access without changing the interface.

    Answer

    Proxy

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