When you design and develop enterprise level automations with UiPath it is extremely important to write a clean, maintainable code. For that developers have to write large number of workflows, each having a single responsibility.
But this comes at a price. Developers need to choose how they will pass the data between workflows, and there are only two options to choose from:
1. Make many input arguments
2. Pass a single input argument of Dictionary type
Both of these options have flaws.
· First option is better from Single Responsibility Principle and Testing standpoint, but wastes a huge amount of developer’s time, and makes development such a tedious process. Especially when pressure on the project is high, it usually makes developers stop caring about clean code. Workflows become big and they perform many things.
· Second option makes development faster by passing only a few arguments, but makes writing tests tedious. More importantly, it is very easy to make a typing mistake when calling specific values by string keys, which again increases debugging time. And worst of all, requires good planning for bigger development teams (Dev A that defines the dictionary needs to let Dev B know about the key names).
Now, what if we could have best of both worlds?
The solution to this problem is good old POCOs (plain old CLR objects) -> .NET classes that carry plain data.
Wouldn’t it be great if we could define class models in C# or VB.NET and just integrate these new classes into an UiPath project, and get all the goodies that come with intellisense (no more typos with Dictionaries, JObjects, XmlElements)?
Also, don’t you hate when working with REST API that you have to parse that huge JSON response into smaller variables or a dictionary or in the worst case pass that huge JObject around?
Not only this, wouldn’t it be great if we could define interfaces, and leverage all the OOP (Object Oriented Programming) concepts to make better, cleaner and maintainable code?
GenerateModelsFromSourceFiles custom activity enables you to do just that.