0
0
LLDsystem_design~10 mins

Separation of concerns 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 separate data storage from business logic.

LLD
class UserRepository:
    def __init__(self):
        self.users = []

    def [1](self, user):
        self.users.append(user)
Drag options to blanks, or click blank then click option'
Aupdate_user
Bget_user
Cdelete_user
Dadd_user
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name that implies retrieval instead of addition.
2fill in blank
medium

Complete the code to separate user interface from data processing.

LLD
class UserInterface:
    def display_user(self, user):
        print(f"User: {user.name}")

class UserProcessor:
    def [1](self, user):
        user.name = user.name.upper()
Drag options to blanks, or click blank then click option'
Aprocess_user
Bdelete_user
Csave_user
Ddisplay_user
Attempts:
3 left
💡 Hint
Common Mistakes
Naming the method display_user which mixes UI with processing.
3fill in blank
hard

Fix the error in the code to properly separate logging from business logic.

LLD
class OrderService:
    def place_order(self, order):
        # Business logic here
        [1].log(f"Order placed: {order.id}")
Drag options to blanks, or click blank then click option'
ALogger
Border
Cself
DOrderService
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'self' or 'order' to call log, mixing concerns.
4fill in blank
hard

Fill both blanks to separate configuration from application logic.

LLD
class AppConfig:
    def __init__(self):
        self.settings = {"db_host": "localhost", "db_port": 5432}

class Application:
    def __init__(self, config):
        self.db_host = config.[1]["db_host"]
        self.db_port = config.[2]["db_port"]
Drag options to blanks, or click blank then click option'
Asettings
Bdb_host
Cdb_port
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to access db_host directly on config instead of inside settings.
5fill in blank
hard

Fill all three blanks to separate data validation, storage, and notification.

LLD
class Validator:
    def validate(self, data):
        return data is not None

class Storage:
    def save(self, data):
        print(f"Saving {data}")

class Notifier:
    def notify(self, message):
        print(f"Notify: {message}")

class Service:
    def __init__(self, validator, storage, notifier):
        self.validator = validator
        self.storage = storage
        self.notifier = notifier

    def process(self, data):
        if self.validator.[1](data):
            self.storage.[2](data)
            self.notifier.[3]("Data processed successfully")
Drag options to blanks, or click blank then click option'
Avalidate
Bsave
Cnotify
Dprocess
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing method names or calling process instead of validate.