We have a legacy code solution in C#. We have to change the code so that it fetches internal data via APIs and not via DB calls.

E.g. if the current code GETS Payment object from DB, we have to replace the logic so that the code calls the GET PAYMENT API instead.

Since there are 100s of code files and multiple DB hits in a single file, doing this manually is not feasible.

I was thinking of building an AI-based tool that would take my code file as input and point me out where I would need to replace the existing code and suggest what API to call at that place.

I have never worked on AI and it would be great if anyone suggests which algorithm to refer for my tool and also how should I proceed with solving the above problem.

  • 1
    $\begingroup$ Welcome to AI stack exchange. Although an AI solution to your problem might be interesting, with current AI tools this would be far harder than the manual process you are trying to avoid. I would expect some automation using regular expressions to be a workable compromise, and it may save you time overall $\endgroup$ Nov 16, 2021 at 12:18
  • $\begingroup$ Thanks, @NeilSlater for your suggestion. Nearly everyone suggested not choosing AI as it would increase complexity! However, upon doing some google research, I stumbled upon something known as Rule-based ML (RBML). Do you think it can be an option? $\endgroup$
    – Jatin
    Nov 17, 2021 at 6:57
  • $\begingroup$ I am not sure what RBML is (you could give a link and I will check - I'd guess something similar to decision trees). The issue will be with the ML part = "Machine Learning". ML works by processing a number of examples, using them to build a function that relates some input (e.g. text of your code) into a value (e.g. true/false on whether to replace with your new call). To do so it typically needs large numbers of examples. Chances are your entire code base does not contain enough examples, so your first task would be to complete the change manually. $\endgroup$ Nov 17, 2021 at 8:14
  • $\begingroup$ en.wikipedia.org/wiki/Rule-based_machine_learning Here's the link. I got your point @NeilSlater. Using ML would need huge data and thus the approach would be too complex. Thanks! If you feel I should research the topics in the above link, kindly let me know. Else I'll proceed with traditional automation :) $\endgroup$
    – Jatin
    Nov 17, 2021 at 9:31
  • $\begingroup$ OK so RBML is a broad category of ML. It would include decision trees as one example - these work by iteratively applying boolean rules that best split a group of examples into similar cases. I think my other comments still stand. Unless someone has already written a useful AI tool to help you find the code you need to re-factor, then creating one and training it on your data yourself will be a large time sink. There are reasons you might do it, e.g. to learn about AI for coding, but saving time on your task is not one of those reasons. $\endgroup$ Nov 17, 2021 at 11:08


You must log in to answer this question.

Browse other questions tagged .