0
0
LLDsystem_design~10 mins

Dependency Inversion Principle 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 declare the high-level module depending on abstraction.

LLD
class HighLevelModule:
    def __init__(self, [1]):
        self.service = service
Drag options to blanks, or click blank then click option'
ALowLevelModule
BConcreteService
Cservice
Dimplementation
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a concrete class instead of an abstraction.
Using a low-level module directly in the high-level module.
2fill in blank
medium

Complete the code to define an abstraction for the service.

LLD
class [1]:
    def operation(self):
        pass
Drag options to blanks, or click blank then click option'
ALowLevelModule
BConcreteService
CHighLevelModule
DServiceInterface
Attempts:
3 left
💡 Hint
Common Mistakes
Naming the abstraction as a concrete class.
Confusing the high-level module with the abstraction.
3fill in blank
hard

Fix the error in the code to make the low-level module implement the abstraction.

LLD
class LowLevelModule([1]):
    def operation(self):
        return "Low level operation"
Drag options to blanks, or click blank then click option'
AServiceInterface
BHighLevelModule
CConcreteService
Dobject
Attempts:
3 left
💡 Hint
Common Mistakes
Inheriting from a concrete class instead of the abstraction.
Not inheriting from any class.
4fill in blank
hard

Fill both blanks to complete the high-level module method calling the service operation.

LLD
class HighLevelModule:
    def __init__(self, service):
        self.service = service

    def execute(self):
        return "High level " [2] self.service.[1]()
Drag options to blanks, or click blank then click option'
Aoperation
B+
C*
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong method name.
Using an incorrect operator.
5fill in blank
hard

Fill all three blanks to complete the dependency injection and usage in the client code.

LLD
service = [1]()
high_level = HighLevelModule([2])
result = high_level.[3]()
Drag options to blanks, or click blank then click option'
ALowLevelModule
Bservice
Cexecute
DServiceInterface
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the abstraction instead of an instance.
Calling a non-existent method.