0
0
Microservicessystem_design~10 mins

High cohesion 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 microservice with high cohesion by focusing on a single business capability.

Microservices
class OrderService {
    public void [1]() {
        // Process order placement logic here
    }
}
Drag options to blanks, or click blank then click option'
AplaceOrder
BhandleUserLogin
CupdateInventory
DsendNotification
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing methods unrelated to the service's main responsibility.
Mixing multiple business capabilities in one service.
2fill in blank
medium

Complete the code to ensure the microservice handles only payment-related tasks, maintaining high cohesion.

Microservices
class PaymentService {
    public void [1]() {
        // Logic to process payment
    }
}
Drag options to blanks, or click blank then click option'
AprocessPayment
BvalidateUserCredentials
CgenerateReport
DmanageShipping
Attempts:
3 left
💡 Hint
Common Mistakes
Adding unrelated methods that reduce cohesion.
Confusing payment processing with other business functions.
3fill in blank
hard

Fix the error in the microservice design by choosing the method that improves cohesion.

Microservices
class InventoryService {
    public void [1]() {
        // Incorrectly placed user authentication logic
    }
}
Drag options to blanks, or click blank then click option'
AauthenticateUser
BupdateStock
CsendEmail
DprocessOrder
Attempts:
3 left
💡 Hint
Common Mistakes
Keeping unrelated methods in the service.
Mixing authentication logic with inventory management.
4fill in blank
hard

Fill both blanks to define a microservice with high cohesion by focusing on user profile management.

Microservices
class UserProfileService {
    public void [1]() {
        // Update user profile details
    }
    public void [2]() {
        // Retrieve user profile information
    }
}
Drag options to blanks, or click blank then click option'
AupdateProfile
BprocessPayment
CgetProfile
DsendNotification
Attempts:
3 left
💡 Hint
Common Mistakes
Including unrelated business logic in the service.
Mixing different responsibilities in one service.
5fill in blank
hard

Fill all three blanks to design a microservice with high cohesion by focusing on shipping operations.

Microservices
class ShippingService {
    public void [1]() {
        // Schedule shipment
    }
    public void [2]() {
        // Track shipment status
    }
    public void [3]() {
        // Calculate shipping cost
    }
}
Drag options to blanks, or click blank then click option'
AscheduleShipment
BtrackShipment
CcalculateShippingCost
DprocessUserLogin
Attempts:
3 left
💡 Hint
Common Mistakes
Adding unrelated methods that reduce cohesion.
Mixing user management with shipping logic.