Existed Code - We can perform CRUD on tenant and also we have business method for same in business layer. Who can perform actions against tenant - Restricted to two users (Role_A & Role_B). TenantController -> TenantService -> TenantDAO
New Scenario - Now we are introducing tenantCategory so older tenants will be known as Tenant_A and new tenants will be known as Tenant_B.
What we did - Used If else in same TenantService code and did what was required for new use case.
- Skip few fields
- Added few new fields
- Added new validations
- Did authorization in same method using if else as initially we were allowing two users (A & B).We used @PreAuthorization but for this new tenant only B can perform the actions.
What can be do better - Can use design pattern to separate the flow. I did some research and get to know suitable design pattern are -
- Strategy
- Decorator
- Visitor
But still not sure which one is suitable pattern.
Techstack - Java 11 & Spring Boot
Aucun commentaire:
Enregistrer un commentaire