DEV Community

Suganya Muthukumar
Suganya Muthukumar

Posted on • Edited on

3 1

Why should we know ALGORITHMS?

Learning has no end, be it any industry we work in. It is inevitable and a continuous process.But,the question is how much do we put to use in our day to day life.

In this post, I specifically like to emphasize on the algorithms we learn, which is considered as a kind of mandate for any Software developer to know. Do we really use Algorithms in our day to day process? Yes, but not in a direct way. Today we have 'N' number of utility packages, to replace all our general use cases.

Few years back, I encountered a problem statement where we had to migrate the data between two completely different data sources. A typical use case was to convert an expression data into a complex JSON structure. Initially it looked like a straight forward approach but the actual implementation was pretty daunting. It was not a problem which can be solved by nested conditions.It needed a much cleaner approach which solves all types of inputs which by definition known as an 'ALGORITHM'.

On a high level, my requirement was to achieve the following conversion.

Input Expression: '(((ABC=AXE))AND((GPR=ADC)))'

Output JSON: { "exp": { "typ": "and", "sbe": [ { "exp": { "typ": "eq", "vtp": "str", "vst": "AXE", "key": "ABC" } }, { "exp": { "typ": "eq", "vtp": "str", "vst": "ADC", "key": "GPR" } } ] } }

No utility packages will come for your rescue to solve such kind of issues. Knowledge on Algorithms changes the way you look at a problem. Many of the use cases can be solved by using the concepts of some algorithms or by tweaking it. But before all the foremost thing required is, spending a quality time to understand the problem statement.

Checkout my code at git hub to know how I tweaked the Expression tree traversal techniques to achieve the desired result.

https://github.com/suganyamuthukumar/ExpressionParsing

Happy Sharing !!

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay