0
0
LLDsystem_design~10 mins

SOLID violations and fixes 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 fix the Single Responsibility Principle violation by separating concerns.

LLD
class UserManager:
    def create_user(self, user_data):
        # code to create user
        pass

    def [1](self, user):
        # code to send welcome email
        pass
Drag options to blanks, or click blank then click option'
Asend_welcome_email
Bdelete_user
Cupdate_user
Dvalidate_user
Attempts:
3 left
💡 Hint
Common Mistakes
Keeping email sending logic inside UserManager class.
Naming methods unrelated to user management.
2fill in blank
medium

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

LLD
class Report:
    def generate(self, report_type):
        if report_type == 'pdf':
            return self.generate_pdf()
        elif report_type == 'csv':
            return self.generate_csv()

    def generate_pdf(self):
        pass

    def generate_csv(self):
        pass

class [1](Report):
    def generate_excel(self):
        pass
Drag options to blanks, or click blank then click option'
AReportService
BExcelReport
CReportGenerator
DReportManager
Attempts:
3 left
💡 Hint
Common Mistakes
Modifying the original Report class to add new report types.
Using generic class names that do not specify report type.
3fill in blank
hard

Fix the error in the code violating the Liskov Substitution Principle by correcting the method signature.

LLD
class Bird:
    def fly(self):
        pass

class Penguin(Bird):
    def [1](self, speed):
        # Penguins cannot fly, so this method should not accept parameters
        pass
Drag options to blanks, or click blank then click option'
Awalk(self)
Bfly(self, speed)
Cswim(self)
Dfly(self)
Attempts:
3 left
💡 Hint
Common Mistakes
Adding extra parameters in subclass methods.
Changing method names in subclass.
4fill in blank
hard

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

LLD
class [1]:
    def print_document(self, document):
        pass

class [2]:
    def scan_document(self, document):
        pass
Drag options to blanks, or click blank then click option'
APrinter
BScanner
CAllInOneMachine
DFaxMachine
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single interface for all functions.
Naming interfaces too broadly.
5fill in blank
hard

Fill all three blanks to fix the Dependency Inversion Principle violation by introducing abstractions.

LLD
class [1]:
    def connect(self):
        pass

class Database:
    def __init__(self, [2]):
        self.connection = [3]

    def query(self):
        self.connection.connect()
Drag options to blanks, or click blank then click option'
AConnectionInterface
Bconnection
Cdb_connection
DDatabaseConnection
Attempts:
3 left
💡 Hint
Common Mistakes
Directly depending on concrete connection classes.
Using inconsistent parameter names.