Hello,
I am here to share about how best to approach the relationship between CW, BL, CS, etc. modules.
So, I will do the development by doing this module approach
CW-> BL> CS
First scenario
CS: contains only non-public entities, and also public server actions, only CRUD actions, and data retrieval on public entities in the form of server actions, (such as FindEmployees, FindEmployeeById),
BL: responsible for accessing data to be retrieved or processed, such as validation, checking roles, from this BL Module will produce an action (FindEmployee) that has been validated from input or roles, and is ready to be used in the CS module.
CW: is the place where the block is created along with the data that will be displayed from the BL module.
Second scenario
CS module performs a public Entity, with read only set, and creates a public server CRUD action without role validation, and
The BL module performs Consume Entity then creates a server action (FIndEmployee), and performs Consume CRUD action, and creates a new CRUD function in the BL module by adding validations such as role and mandatory input, to be ready for use in CW.
The third scenario
where the CS module, the public entity is read-only, remains a CRUD action, also validated directly, such as mandatory and role validations, in the CS module, after which it is made public.
and the BL module will consume the CS module.
why don't I use the CS module on CW?
because in the case that I experienced before,
where there is a change in the filter on the data that must be displayed, so I have to replace or update the filter on each aggregate created at the screen level.
So with the approach of creating Action Data or data that has been wrapped in server actions, it is hoped that it can be reused and only replace one or several actions when there are additional filters or others so that each screen has adjusted.
The question is, which approach is best from the above cases or scenarios?
and when to use or place actions or components in CW module, BL module or CS Module?
Thank you very much
Hi Rijal RF,
The best approach among the scenarios depends on your need for modularization and security. Option for the second or third scenario if stronger role validation and data encapsulation are required. Use CW for UI components only and keep business logic and data access confined to BL and CS for clear separation of concerns. This method ensures easier updates and better reusability of server actions, especially when changes are required in the data filters.
Thanks,
Vipin Yadav
I would like to understand why the first scenario is not recommended. Could you please provide the reasons for it? I will try to understand it better.
Thank you again for your great suggestions!
In the first scenario, OutSystems modular architecture principles are not fully applied because CS should expose only essential public data or actions for reuse without specific business logic. Instead, data retrieval should occur in BL to maintain separation of concerns, ensuring that CS focuses on data access while BL manages validations and processing for CW.
The best approach depends on the complexity of your application:
Scenario 1 (Recommended for Enterprise Applications):
Scenario 2 (For Mid-Sized Applications):
Scenario 3 (For Small Applications):
Avoid using CS in CW to prevent scattered logic. Use BL to centralize data processing, so changes affect all screens consistently. Scenario 1 is the most maintainable for complex projects.
Hi @Gourav Shrivastava ,
I think for option 3, you meant to say 'directly uses CS' ? right ?
I think this is a very complete and nuanced answer, I personally think
Dorine
Hi @Dorine Boudry
I agree that validations tied to database integrity or entity-level rules can be handled in CS. However, I focus on centralizing reusable queries or update actions in BL to avoid scattered logic and ensure easier maintenance, especially in complex systems.
Appreciate your insights!
Thanks
Regards Gourav Shrivastava
Thank you for the very helpful answer!
I have related doubts
Can public module_CS actions / entities be consumed by other Model_CS?