UiPath Coding Standardization to follow while Development?

Hi There,

I want to know what the standardization developer are needed to follow while developing code. Like, Naming conventions, Annotations, minimal use of If statements, etc.

Could you please mention all the TO DO’s & NOT TO DO’s

Thanks

@Muralikrishna_Surve
When developing code in UiPath, it is important to follow certain best practices and coding standards to ensure readability, maintainability, and efficiency. Here are some general recommendations for UiPath development:

TO DO’s:

  1. Use meaningful and descriptive names for variables, arguments, activities, and workflows to enhance code understanding.
  2. Use annotations and comments to provide explanations for complex logic, highlight important details, and improve code documentation.
  3. Modularize your code by breaking it into reusable workflows and libraries for better maintainability and reusability.
  4. Implement error handling and exception handling mechanisms to gracefully handle errors and unexpected situations.
  5. Follow the principle of reusability by creating and using custom activities, templates, and workflows.
  6. Make use of logging activities to track and troubleshoot issues during execution.
  7. Utilize version control systems (such as Git) to manage your code and collaborate with other developers.
  8. Regularly test and validate your code to ensure its correctness and reliability.
  9. Optimize performance by minimizing unnecessary delays, excessive logging, and large data transfers.
  10. Keep the workflow design simple and easy to understand by avoiding complex and convoluted logic.

NOT TO DO’s:

  1. Avoid using hardcoded values directly in your code. Utilize configuration files or input parameters to provide flexibility and maintainability.
  2. Avoid excessive use of global variables. Instead, prefer passing variables as arguments between workflows to maintain a clear data flow.
  3. Avoid using large workflows with multiple responsibilities. Split them into smaller, more focused workflows for better organization and readability.
  4. Do not ignore error handling. Handle exceptions and errors appropriately to ensure the stability and reliability of your automation.
  5. Avoid unnecessary or redundant activities. Review and optimize your code to eliminate any unused or duplicate activities.
  6. Do not hardcode usernames, passwords, or sensitive information directly in your workflows. Utilize secure credential storage mechanisms provided by UiPath.
  7. Avoid complex and nested If statements. Consider using switch statements or other control flow activities for improved readability.
  8. Do not neglect proper documentation. Document your code, workflows, and activities to facilitate understanding and future maintenance.
  9. Avoid excessive delays or wait activities without valid reasons. Optimize delays to reduce unnecessary waiting time during execution.
  10. Do not neglect testing. Thoroughly test your automation to identify and address any issues before deployment.
1 Like

Hi,

Refer these:

UiPath Automation Coding Best Practices | Community Blog

Orchestrator - Automation Best Practices (uipath.com)

1 Like

Hey @raja.arslankhan

Could you please give TO DO’s with examples for better understanding or else you can share any workflow if available.

TO DO’s:

  1. Naming format to follow for Var, Arg and Activities names.
  2. How many activities is enough in 1 workflow?
  3. As far as I know using delay is not good practice. May I know alternative for this ?

Thanks

Hi @Muralikrishna_Surve

You can follow these playlist 1. UiPath RPA Developer Best Practices | Workflow Type in UiPath | RPA Projects | #shorts - YouTube. This playlist helps you in understanding of best practices and in implementation in projects also.

Regards
Naman Jain

1 Like

@Muralikrishna_Surve

When naming variables, arguments, and activities in UiPath, it is important to follow best practices for clear and meaningful names that are easy to understand and maintain. Here are some examples of naming formats to consider:

Variables:

  1. Use camelCase: customerName, orderCount, totalAmount
  2. Prefix with data type abbreviation: strCustomerName, intOrderCount, dblTotalAmount
  3. Include scope or context: localCustomerName, globalOrderCount

Arguments:

  1. Use camelCase: inputData, outputResult
  2. Prefix with direction abbreviation: in_CustomerData, out_ResultData, io_ResultData
  3. Include purpose or context: configSettings, transactionData

Activities:

  1. Use PascalCase: Assign, If, For Each, Invoke Workflow
  2. Include action or purpose: AssignOrderTotal, IfCustomerExists, For EachRowInDataTable, InvokeProcessWorkflow

Additional Tips:

  1. Be descriptive: Use names that clearly convey the purpose or content of the variable, argument, or activity.
  2. Avoid abbreviations or acronyms unless they are widely understood and consistent within your project/team.
  3. Use consistent and meaningful prefixes or suffixes for variables or arguments related to specific data types or purposes, such as str for strings, int for integers, or config for configuration settings.

Here are some best practices regarding the number of activities in a workflow:

  1. Single Responsibility Principle: Each workflow should have a single responsibility or perform a specific task. This helps in making the workflow easier to understand, debug, and modify.
  2. Break down complex processes: If a process is complex and involves multiple steps, consider breaking it down into smaller, more manageable workflows or sequences. This allows for better organization and reusability of activities.
  3. Avoid excessively long workflows: Long workflows with a large number of activities can become difficult to navigate and understand. If possible, split long workflows into smaller, logical units or sub-workflows.
  4. Modular design: Design workflows in a modular manner, where each module or sub-workflow handles a specific task or performs a specific function. This promotes reusability and makes it easier to update or modify specific parts of the automation.
  5. Balance between granularity and readability: While it’s important to break down complex processes into smaller workflows, be mindful not to overdo it. Aim for a balance between granularity and readability. Having too many tiny workflows may lead to excessive navigation and maintenance overhead

Here are some alternatives of delay

  1. Activity-specific Wait: Instead of using a generic delay, some activities have built-in options to wait for specific conditions to be met. For example, you can use the “Element Exists” activity to wait until an element appears on the screen or use the “Wait Attribute” activity to wait until a specific attribute of an element changes.
  2. Timeout and Retry Mechanisms: Rather than using a fixed delay, you can implement timeout and retry mechanisms. For instance, you can set a timeout value and periodically check for the desired condition or element within a loop, and if the condition is not met within the specified time, you can exit the loop or take appropriate action.
  3. Event-Based Triggers: In some cases, you can design your automation to trigger based on specific events or conditions. Instead of relying on delays, you can configure your workflow to wait for an event or signal before proceeding to the next step. This can be achieved using activities like “On Element Appear” or by utilizing system events or triggers.
  4. Synchronization Techniques: If your automation involves multiple parallel processes or interactions with external systems, you can use synchronization techniques to ensure that activities are executed in the correct order. Techniques like mutexes, semaphores, or custom synchronization mechanisms can be implemented to coordinate the flow of your automation.
  5. Intelligent Waits: Intelligent wait techniques involve dynamically waiting for an action to complete before proceeding. This can be achieved by using activities that provide synchronization options, such as “Wait Image Vanish” or “Wait for Ready” properties available in certain activities.
4 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.