I have gone through one of the internal discussion posted by product specialist and understood that , we usually recommend against using Top in Data Transforms because the handling of "Top" can change based on when and where it is used in surprising ways.
The root cause of the problem is that "Top" is a special keyword that is not always handled by all assembly code. It will likely be handled correctly by actions such as Set, which are primarily handled by the expression parser, but may not be handled properly by other actions such as Update Page, which does not use always use the expression parser. Additionally, Top as a concept is odd and type-unsafe. Since an embedded page can be included at any point in the model, we can never accurately predict the type of Top. Further, the system does no type checking at run-time to ensure that the type of top declared on Pages & Classes matches the run-time type. It is equivalent to an unchecked cast. This lack of type enforcement can lead to anything from run-time errors to silently incorrect behaviour. Personally, I would not recommend the usage of Top, but I understand its utility when writing real world applications.
Please Let me know if it helps you.
Posted: 6 years ago
Posted: 31 May 2016 6:42 EDT
Wojtek Nowak (Wojtek)
that is an interesting question and also a very interesting answer. Thank You!
From the perspective of Pega in practice, I have seen a lot of projects that just couldn't do without the Top keyword. Now, if that is discouraged (as well as explicit references to pyWorkPage), what is the alternative way to do it?
On that note, I can't really grasp why the use of the keyword Parent is also limited to a handful of rule types. From an object-oriented stand-point, it is a fundamental concept to be able to access the parent's properties and behaviour (i.e. activities / data transforms in Pega). In languages like Java You'd simply use super to access the parents attributes and methods. In Pega there is no such thing, is there?
Reading all these discussions above , can understand the use of Top keyword might vary based on context of use...so can anyone please answer Top can be used in any embedded page structure or only when the embedded page structure exists in a loop...
Posted: 4 years ago
Posted: 26 Mar 2018 5:25 EDT
Lochana Durgada Vijayakumar (Lochan_DV)
Senior Manager, Knowledge Management
Thank you for posting your query on PSC. This looks like an inactive post and hence, we suggest you create a new post for your query. Click on the Write a Post button that’s available on the top right pane of this page.
Thank you for posting your query on PSC. This looks like an inactive post and hence, we suggest you create a new post for your query. Click on the Write a Post button that’s available on the top right pane of this page. Once created, please reply back here with the URL of the new post.
We have also sent you a private message opening up a communication channel in case you have any further questions.