Please clarify whether we can have same rules in the different class.
For Example:
Test-FW-XYZ-Work
FlowActionA
SectionA
Test-FW-XYZ-Work-Module1
FlowActionA
SectionA
Test-FW-XYZ-Work-Module2
FlowActionA
SectionA
Can we consider the highlighted rules in XXX-Module1 and XXX-Module2 as a duplicate rules, as rules are available in the XX-Work layer.
Inheritance and re-usability concepts are ignore & bypassed?
or
This is encouraged in pega whenever the concept of dynamic polymorphism is required instead of creating a new rule with other name and changing all the associated references
From the above example Inheritence is not ignored. The reason is the above example follows the overriding concept.
Here I am adding one more class Test-FW-XYZ-Work-Module3 which does not inherit the Flow actions or section. So now lets consider the workobjects of each
From Workobject of XXX-Module1 if we invoke the FlowactionA then it will access FlowActionA from XXX-Module1 class.
From Workobject of XXX-Module2 if we invoke the FlowactionA then it will access FlowActionA from XXX-Module2 class.
From Workobject of XXX-Module3 if we invoke the FlowactionA then it will access FlowActionA from Test-FW-XYZ-Work Parent class.
Refer the image.
So to answer your question for better maintanence I feel that instead creating a new rule and changing the reference the above would be better approach.
In the highlighted scenario, If the change/specification is common for all the classes. Do we need to change the section and flow action changes at all the classes?
Is it still valid to have the rules in all the three class?
Can we optimize/justify to have it in the parent class for reusability?
Mean we will update the section and flow action in Test-FW-XYZ-Work. Instead of having the changes in class in Test-FW-XYZ-Work-XXX-Module1 &Test-FW-XYZ-Work-XXX-Module2.
→ “Overriding is a feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super-classes or parent classes.”
By considering the definition of overriding, to answer your question
If the changes are common we can have those in the parent class ( XXX-Work) itself. Module specific implementation only we can have it in the Module classes.
Yes it is valid to have same rules in the class hierarchy in case of overriding (In need of specific implementation for child class)
Yes, As you mentioned, in your case if the changes are common for all modules we no need to have Flowactions/sections in each module we can define in Parent class and reuse for all child classes. YES we achieved reusability here.