-
Notifications
You must be signed in to change notification settings - Fork 147
Architecture Rules
This rule try to enforce the usage of AsyncClient variants of AWS SDK, for example the usage of kmsAsyncClient
instead of kmsClient
in reactive flows using the Mono.fromFuture
method.
This rule is intended to avoid the technical names usage in domain entities. We avoid UserDTO name instead of simply define as User.
This rule is intended to avoid the technical names usage in domain entities, gateways and use cases. We avoid DynamoUserGateway name instead of simply define as UserGateway.
The same purpose of Rule_2.4
but applied to domain model fields or use case fields.
This rule is designed to avoid the shared resources in concurrency, all dependencies of a Use Case should be immutable, and each context call should have their own resources.
No compliant
package co.com.bancolombia.usecase.notifyusers;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class NotifyUsersUseCase {
private NotificationGateway notifier; // No Compliant
private User user; // No Compliant
public void notify(User user){
this.user = user;
// some other business logic
this.sendMessage()
}
private void sendMessage(){
// send message througth class instance of user
notifier.send("notification", user.getEmail())
}
}
Compliant
package co.com.bancolombia.usecase.notifyusers;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class NotifyUsersUseCase {
private final NotificationGateway notifier; // Compliant
public void notify(User user){
// some other business logic
this.sendMessage(user)
}
private void sendMessage(User user){
// send message througth input instance of user
notifier.send("notification", user.getEmail())
}
}
Rule_2.7: Beans classes should only have final attributes (injection by constructor) to avoid concurrency issues
This rule is designed to avoid the shared resources in concurrency, all dependencies of a Bean should be immutable, and each context call should have their own resources. We promote the dependencies injection through constructor over the @Value annotated fields injection.
No Compliant
@Component
public class MyService {
@Value("${external-service.endpoint}")
private String endpoint; // No Compliant
public void someFunction(SomeObject domainObject){
// ... logic that uses endpoint
}
}
Compliant
@Component
public class MyService {
private final String endpoint; // Compliant
public MyService(@Value("${external-service.endpoint}") String endpoint) {
this.endpoint = endpoint;
}
public void someFunction(SomeObject domainObject){
// ... logic that uses endpoint
}
}