0
0
LLDsystem_design~10 mins

Applying SOLID to real code 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 apply the Single Responsibility Principle by separating concerns.

LLD
class UserManager:
    def __init__(self, user_repository):
        self.user_repository = user_repository

    def [1](self, user):
        self.user_repository.save(user)
Drag options to blanks, or click blank then click option'
Asave_user
Bdelete_user
Cupdate_user
Dget_user
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic method name that mixes multiple responsibilities.
Naming the method something unrelated to saving.
2fill in blank
medium

Complete the code to follow the Open/Closed Principle by allowing extension without modification.

LLD
class NotificationSender:
    def send(self, message):
        [1]
Drag options to blanks, or click blank then click option'
Apass
Bprint('Send notification')
Creturn None
Draise NotImplementedError()
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the method empty with pass, which does not enforce implementation.
Returning None, which silently ignores the missing implementation.
3fill in blank
hard

Fix the error in the code to comply with the Liskov Substitution Principle.

LLD
class Bird:
    def fly(self):
        print('Flying')

class Penguin(Bird):
    def [1](self):
        print('Swimming')
Drag options to blanks, or click blank then click option'
Afly
Bwalk
Cswim
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Overriding fly to raise an exception, breaking substitutability.
Not providing alternative behavior for Penguin.
4fill in blank
hard

Fill both blanks to apply the Interface Segregation Principle by splitting interfaces.

LLD
class PrinterInterface:
    def print_document(self):
        pass

class ScannerInterface:
    def [1](self):
        pass

class MultiFunctionDevice(PrinterInterface, ScannerInterface):
    def print_document(self):
        print('Printing')
    def [2](self):
        print('Scanning')
Drag options to blanks, or click blank then click option'
Ascan_document
Bfax_document
Ccopy_document
Dsend_email
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated method names that do not represent scanning.
Mixing fax or email methods which are not part of scanning.
5fill in blank
hard

Fill all three blanks to apply the Dependency Inversion Principle by depending on abstractions.

LLD
class DatabaseInterface:
    def [1](self, data):
        pass

class MySQLDatabase(DatabaseInterface):
    def [2](self, data):
        print(f"Saving {data} to MySQL")

class DataManager:
    def __init__(self, db: DatabaseInterface):
        self.db = db
    def save(self, data):
        self.db.[3](data)
Drag options to blanks, or click blank then click option'
Asave_data
Bsave
Cstore
Dinsert
Attempts:
3 left
💡 Hint
Common Mistakes
Using different method names causing mismatch.
Calling concrete class methods directly instead of interface methods.