0
0
Microservicessystem_design~10 mins

Bounded context mapping 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 a bounded context in a microservices architecture.

Microservices
class [1]Context:
    def __init__(self):
        self.services = []
Drag options to blanks, or click blank then click option'
AInventory
BDatabase
CUser
DPayment
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'Database' as a bounded context, which is a technical concern, not a domain context.
2fill in blank
medium

Complete the code to show how two bounded contexts communicate via an API gateway.

Microservices
class APIGateway:
    def __init__(self):
        self.contexts = [[1]Context(), OrderContext()]
Drag options to blanks, or click blank then click option'
AUser
BPayment
CShipping
DInventory
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting a context unrelated to user management for this example.
3fill in blank
hard

Fix the error in the code that incorrectly maps bounded contexts.

Microservices
def map_contexts():
    contexts = ['User', 'Order', 'Payment']
    for context in contexts:
        if context == [1]:
            print('Handle user context')
Drag options to blanks, or click blank then click option'
A"Order"
B'User'
C'Payment'
DUser
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing string elements without quotes causing a NameError.
4fill in blank
hard

Fill both blanks to correctly define a context map with upstream and downstream contexts.

Microservices
context_map = {
    'Order': {'upstream': [1], 'downstream': [2]
}
Drag options to blanks, or click blank then click option'
A'User'
B'Payment'
C'Inventory'
D'Shipping'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing upstream and downstream contexts or using unrelated contexts.
5fill in blank
hard

Fill all three blanks to complete the code that models a shared kernel between two bounded contexts.

Microservices
shared_kernel = {
    [1]: ['Address', 'ContactInfo'],
    [2]: ['Address', 'PaymentTerms'],
    [3]: ['Address']
}
Drag options to blanks, or click blank then click option'
A'UserContext'
B'OrderContext'
C'SharedEntities'
D'PaymentContext'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing context names or misplacing the shared entities key.