Bird
0
0
LLDsystem_design~10 mins

Null Object pattern in LLD - Interactive Code Practice

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

Complete the code to define a Null Object class that implements the same interface.

LLD
class NullLogger:
    def log(self, message):
        [1]
Drag options to blanks, or click blank then click option'
Apass
Bprint(message)
Creturn message
Draise Exception('Not implemented')
Attempts:
3 left
💡 Hint
Common Mistakes
Using print or return instead of pass.
2fill in blank
medium

Complete the code to use the Null Object pattern to avoid null checks.

LLD
def process(logger):
    logger.[1]('Start processing')
Drag options to blanks, or click blank then click option'
Alog
Bwrite
Cprint
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names not defined in the interface.
3fill in blank
hard

Fix the error in the Null Object implementation to correctly override the interface method.

LLD
class NullNotifier:
    def notify(self):
        [1]
Drag options to blanks, or click blank then click option'
Araise NotImplementedError()
Bprint('Notification sent')
Creturn True
Dpass
Attempts:
3 left
💡 Hint
Common Mistakes
Raising exceptions or printing output in Null Object methods.
4fill in blank
hard

Fill both blanks to complete the factory method that returns a Null Object when input is None.

LLD
def get_logger(logger):
    if logger is None:
        return [1]()
    else:
        return [2]
Drag options to blanks, or click blank then click option'
ANullLogger
Blogger
CLogger
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Returning None instead of Null Object instance.
5fill in blank
hard

Fill all three blanks to implement a Null Object pattern with a dictionary comprehension filtering active users.

LLD
active_users = {user: [1] for user, status in users.items() if status [2] 'active' and user != [3]
Drag options to blanks, or click blank then click option'
ANullNotifier()
B==
CNone
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators or values in comprehension.