DEV Community

Suganya Muthukumar
Suganya Muthukumar

Posted on • Updated on

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 !!

Top comments (0)