Complete the code to define the Anti-corruption Layer interface.
class AntiCorruptionLayer { public void translate([1] input) { // translation logic } }
The Anti-corruption Layer translates from the external model, so the input should be the external model.
Complete the code to implement the Anti-corruption Layer adapter method.
public InternalModel adapt([1] external) { // mapping logic return new InternalModel(); }
The adapter method takes an external model as input to convert it into an internal model.
Fix the error in the Anti-corruption Layer pattern where the internal system is directly coupled to the external system.
public class InternalService { private ExternalService externalService; public void process() { var data = externalService.getData(); var internalData = [1](data); // process internalData } }
The internal service should use an adapter to translate external data, avoiding direct coupling.
Fill both blanks to complete the request flow through the Anti-corruption Layer.
ExternalSystem -> [1] -> [2] -> InternalSystem
The request first hits the External API, then passes through the Anti-corruption Layer before reaching the internal system.
Fill both blanks to complete the dictionary comprehension for filtering and transforming data in the Anti-corruption Layer.
filtered_data = {k:v for k, v in data.items() if v [1] 10 and 'valid' [2] k}The dictionary comprehension uses ':' to map keys to values, filters values greater than 10, and keys containing 'valid'.