Bird
0
0
LLDsystem_design~10 mins

Why behavioral patterns define object interaction in LLD - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to show how behavioral patterns focus on {{BLANK_1}}.

LLD
class Observer:
    def update(self, [1]):
        pass
Drag options to blanks, or click blank then click option'
Astate
Bclass
Cmethod
Dvariable
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing state with class or method names.
2fill in blank
medium

Complete the code to illustrate object interaction in behavioral patterns.

LLD
class Subject:
    def __init__(self):
        self.observers = []

    def attach(self, observer):
        self.observers.[1](observer)
Drag options to blanks, or click blank then click option'
Aremove
Bappend
Cclear
Dpop
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove or pop which delete items instead of adding.
3fill in blank
hard

Fix the error in the code that manages object interaction.

LLD
class Command:
    def execute(self):
        [1]
Drag options to blanks, or click blank then click option'
Aexecute()
Breturn
Cpass
Dself.execute()
Attempts:
3 left
💡 Hint
Common Mistakes
Calling execute() inside itself causing infinite recursion.
4fill in blank
hard

Fill both blanks to complete the interaction between objects in the Chain of Responsibility pattern.

LLD
class Handler:
    def __init__(self, successor=None):
        self.successor = [1]

    def handle(self, request):
        if self.can_handle(request):
            self.process(request)
        else:
            if self.successor is not [2]:
                self.successor.handle(request)
Drag options to blanks, or click blank then click option'
Asuccessor
BNone
Cself
Drequest
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names or forgetting to check for None.
5fill in blank
hard

Fill all three blanks to complete the Mediator pattern example showing object interaction.

LLD
class Mediator:
    def notify(self, sender, event):
        if event == [1]:
            self.colleague1.[2]()
        elif event == [3]:
            self.colleague2.action()
Drag options to blanks, or click blank then click option'
A"event1"
Brespond
C"event2"
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing event names or method names incorrectly.