Variable naming convention

Hello everybody.

Just a quick question.

I have recently been learning and using modern design using the c# language and learning c# and coded workflows in general. This has led me to doing Microsofts foundational c# course.

In the course they state when naming variables not to include the datatype i.e. str_firstName or strFirstName.

I was just wondering what the current best practices are as looking at the documentation I couldn’t find any info on prefixing.

Sorry if this has already been asked recently.

1 Like

HI,

Microsoft recommends not to use Hungarian notation : such as strVar, intVar etc.

I think It’s unnecessary to add type prefix basically. However, in UiPath (especially workflow), as type definition is separated from designer panel, it may be allowed to add prefix for improving readability, in some organization.

Regards,

1 Like

Hi

These are some example I would use always,

If its string datatype and username strUsername (these are called camelcase formatting ) and if it’s int datatype and may be used for Numbers then it is intNumber
So it’s variables datatypes first (str,int,bool etc) and then the actual name (username, password,email etc)

For datatable I would use dtTable or dtSourcetable based on the excel data.

For arguments put in_username(for in argument) ,out_username(for out argument) , in_out_username(for in/out arguments)

Thank you

@k-morgan Studio’s Workflow Analyzer has built-in rules which is a good place to start: https://docs.uipath.com/studio/standalone/2023.4/user-guide/naming-rules

Here’s an example for variable names: https://docs.uipath.com/studio/standalone/2023.4/user-guide/st-nmg-001

You can modify these rules based on your preference as you gain more experience.

Thanks!

Meaningful names should be assigned to workflow files, activities, arguments, and variables in order to accurately describe their usage throughout the project.

Projects should have meaningful descriptions, as they are also displayed in the Orchestrator user interface and might help in multi-user environments.

To improve readability, variable and argument names should also align to a naming convention:

  • Snake case: First1_Name2, first_name2,
  • Upper or lower Camel case: FirstName, lastName,
  • Pascal case: First1Name2, First1Name,
  • Kebab case: First-Name, First-Name1.

Argument names should have a prefix stating the argument type, such as in_DefaultTimeout, in_FileName, out_TextResult, io_RetryNumber.

Activity names should concisely reflect the action taken, such as Click the Save Button. Keep the part of the title that describes the action (Click, Type Into, Element Exists, etc.).

Except for Main, all workflow names should contain the verb describing what the workflow does, such as GetTransactionData, ProcessTransaction, TakeScreenshot.

Check these documents for more details

UiPath Knowledge base on naming convention

Hope this helps

Cheers @k-morgan