0
0
Microservicessystem_design~10 mins

Anti-corruption layer in Microservices - 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 the Anti-corruption Layer interface.

Microservices
class AntiCorruptionLayer {
    public void translate([1] input) {
        // translation logic
    }
}
Drag options to blanks, or click blank then click option'
AExternalModel
BInternalModel
CServiceResponse
DDataTransferObject
Attempts:
3 left
💡 Hint
Common Mistakes
Using internal models as input instead of external models.
2fill in blank
medium

Complete the code to implement the Anti-corruption Layer adapter method.

Microservices
public InternalModel adapt([1] external) {
    // mapping logic
    return new InternalModel();
}
Drag options to blanks, or click blank then click option'
AServiceRequest
BInternalModel
CExternalModel
DDataEntity
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing input and output types in the adapter method.
3fill in blank
hard

Fix the error in the Anti-corruption Layer pattern where the internal system is directly coupled to the external system.

Microservices
public class InternalService {
    private ExternalService externalService;

    public void process() {
        var data = externalService.getData();
        var internalData = [1](data);
        // process internalData
    }
}
Drag options to blanks, or click blank then click option'
AexternalService.getData
BinternalService.transform
CexternalService.processData
Dnew Adapter().adapt
Attempts:
3 left
💡 Hint
Common Mistakes
Calling external service methods directly without translation.
4fill in blank
hard

Fill both blanks to complete the request flow through the Anti-corruption Layer.

Microservices
ExternalSystem -> [1] -> [2] -> InternalSystem
Drag options to blanks, or click blank then click option'
AAntiCorruptionLayer
BExternalAPI
CInternalAPI
DAdapter
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing the order of components in the flow.
5fill in blank
hard

Fill both blanks to complete the dictionary comprehension for filtering and transforming data in the Anti-corruption Layer.

Microservices
filtered_data = {k:v for k, v in data.items() if v [1] 10 and 'valid' [2] k}
Drag options to blanks, or click blank then click option'
A:
B>
Cin
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators or missing colon in comprehension.