Learn Pega | Practice | Crack Interviews
pegaguide@gmail.com


When you started learning pega for the first time, why most of the mentors don't say about the concepts related to activities? When you start building your application, why architects says to eliminate activity rules and go with other rule types instead? Why does pega shows guardrail warning when you create an activity?

As a pega developer, when ever we started thinking of a use case, our minds automatically think about writing an activity as a first option. As the activity provides lot of options and its look like a algorithm or program that we are comfortable with. But why pega suggests to limit the activity usage, what happens if we create an activity rule. Most of us have this kind of similar question in our minds. Lets us go back to the basics and understand the real reason behind all of this.


What are activities?

Activity rules are most like traditional computer programs, in that they consist of a sequence of steps that are typically performed in order. Activity contains series of steps and each step contains a operation known as a method. For example, an activity can fetch a work item from the database, compute new values for some of the properties in the work item, and save the updated work item back into the database. An activity rule can perform computations, create, update, or delete objects, or support user interactions.

Key Features

Most activities contain no more than 20 steps. Activities work in sequence order or can jump ahead to a later-numbered step, identified by a label, based on a conditional test.

  • contain a sequence of procedural, atomic steps that are by default executed top down
  • reference a specific instruction (known as a method) in each step
  • can perform calculations
  • can retrieve, update and save data
  • can call other activities
  • can contain loops or iterations




  • Problems with Activities

    1. Prone to security

    As we can write java steps or java script inside the activities, these are prone to many security attacks. Java code has to be properly written to prevent our application from many security attacks like Injection and Cross-site scripting.

    2. Infinite loops, deadlocks

    Some times, due to bad coding or unanticipated input, it might go to infinite loop and results in deadlocks. Out of the box, all pega rule types handles these scenarios, but activity logic is custom written, it depends on the developer and make sure that developer shouldn't endup with spaghetti code

    3. Complexity and Maintainability Issues

    Unlike other rule types, activities can bring complexity to your system. Its very difficult to analyze and debug the issues that involved with activity rule. Activity rules are important to understand and use when appropriate, but activities are not the dominant or primary rule type used in an application.

    4. Activities are not declarative

    The powerful feature of Pega is to invoke the rules decoratively, like Data page, Declare Expression, Declare Index, Declare On Change etc. The activities does not have the ability to invoke themselves declratively, we need to specify in procedural fashion somewhere in our flow. This doesn't leverage the most powerful feature of pega.


    5. Activities limits your knowledge

    Because of the size and power of the activities, developers may not think of any other option and try to achieve with activity rules. It Costs valuable time to develop, debug, and maintain.

    So guys, from now onwards, try to reduce the usage of activities and go with other ruletypes provided by pega. Activity is the last option that we should think off. For every release, pega is providing a new and enhanced set of capabilities to eliminate the activity usage, we can discuss about the new features in the next article. Finally, good practice in pega doesn't encourage you to create activities.

    If you like PegaGuide and would like to contribute, you can also write an article and mail your article to pegaguide@gmail.com. See your article appearing on the Pega Guide and help other Pega Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

    Leave a comment