DEV Community

Cover image for HOW HARD CAN IT BE?
Bala Madhusoodhanan
Bala Madhusoodhanan

Posted on

HOW HARD CAN IT BE?

Intro:
At first glance, converting numbers to text might seem like a straightforward task. Last week writing a c# code was super fun to enable the Fusion development with power platform.

This week, I wanted to see how challenging it would be to achieve the same result using native expression. However, as with any journey, the path is rarely as simple as it appears.

Is It Really that Simple???

We’ll break down the concepts, step-by-step, and uncover the nuances that make this task both intriguing and challenging.

Setup look up variables:

Units Teens Tens
{
"0": "",
"1": "one",
"2": "two",
"3": "three",
"4": "four",
"5": "five",
"6": "six",
"7": "seven",
"8": "eight",
"9": "nine"
}
{
"10": "ten",
"11": "eleven",
"12": "twelve",
"13": "thirteen",
"14": "fourteen",
"15": "fifteen",
"16": "sixteen",
"17": "seventeen",
"18": "eighteen",
"19": "nineteen"
}
{
"2": "twenty",
"3": "thirty",
"4": "forty",
"5": "fifty",
"6": "sixty",
"7": "seventy",
"8": "eighty",
"9": "ninety"
}

Extracting each part of the number

  • Code snippet used to extract the millions part of a large number. In the example of 1,237,654, it helps identify that there is 1 million in the number.
div(int(variables('Number')), 1000000)
Enter fullscreen mode Exit fullscreen mode
  • Code used to extract the thousands part of a large number.In the example of 1,237,654, it helps identify that there are 237 thousands in the number.
mod(div(int(variables('Number')), 1000), 1000)
Enter fullscreen mode Exit fullscreen mode
  • extracting hundreds
mod(div(int(variables('Number')),100),10)
Enter fullscreen mode Exit fullscreen mode
  • extracting tens
mod(int(variables('Number')),100)
Enter fullscreen mode Exit fullscreen mode

If the value is set to any of the above steps, then convert the millions part of a number into its text representation and append the word “Million” to it

concat(variables('Units')[string(variables('Millions'))],' Million ')
Enter fullscreen mode Exit fullscreen mode

You append the string variable as you go through all the different level of extraction

The flow is little big

Image description

Demo:

demo

What i learned:

Bringing Pro-Code with the low code ecosystem offers flexibility and depth needed to manage complex logic, greater ease in making changes and maintaining the system over time, ensuring long-term sustainability and adaptability

Theme Description Low code Fusion Code
Logic Development Higher complex logic for a process Hard Easy
Technical Debt Manifests as poorly written code, outdated dependencies, and unresolved issues that impede the system’s maintainability and stability. Hard Easy
Easy of making change Due to its tangled and fragile nature, making changes or adding new features to the system becomes increasingly difficult and risky Hard Easy
Maintainace Maintaining and debugging the system becomes a time-consuming and labor-intensive task. Hard Easy
Environmental Impact More compute and hence on the Hard Easy

Closing Remark:
Low-code solutions often fall short due to their limitations in handling sophisticated requirement. Low-code can be a valuable tool for simpler applications and rapid prototyping, the fusion / bring the Pro-code enables us to tackling more complex and demanding logic.

Image description

These challenges can provide valuable lessons for future improvements

Top comments (2)

Collapse
 
dreama profile image
Dream

This was really informative! How would this approach handle very large numbers beyond the millions, say in the billions or trillions range? Could be interesting to see in a future post.

Collapse
 
balagmadhu profile image
Bala Madhusoodhanan

i would still prefer to use the custom C# code as it would be more easy to manage and support .