Please Wait For Loading
In this post How to generate website using Chat GPT I checked how ChatGPT is doing with generating the layout.
Today, we will see how it copes with the refactoring.
var x = 5; var a = x; var b = a; var c = b; Console.WriteLine(c); var d = c; var e = d; var f = e + 1; var g = f; var h = g; Console.WriteLine(g);
That’s not exactly what I meant.
Let’s try it differently.
Much better.
int[] numbers = { 1, 2, 3, 4, 5 }; var result = numbers .Where(n => n % 2 == 0) .Select(n => n * n) .OrderByDescending(n => n) .Skip(1) .TakeWhile((n, index) => index < 2 || n > 10) .Sum(); Console.WriteLine(result);
Okay, time to ask ChatGPT what can we do with this piece of code.
I’m pasting here the code provided by ChatGPT, which allows you to verify that I’m not lying.
int[] numbers = { 1, 2, 3, 4, 5 }; var result = numbers .Where(n => n % 2 == 0) .Select(n => n * n) .OrderByDescending(n => n) .TakeWhile((n, index) => index < 2 || (index == 2 && n > 10)) .Sum(); Console.WriteLine(result);
This code changes the result. The original code returned 4, but now it’s 20. Tell that to ChatGPT and watch how it will react.
Ok, let’s see.
ChatGPT said that this code would now return 4 as a result, but as you can see, it’s still 20.
My answer for this is
Yes, I know ChatGPT is capable of performing good refactoring, but we still need to double-check everything based on ChatGPT’s answer.
ChatGPT is wonderful tool, but again – it’s not medicine for every problem.
Save my name, email, and website in this browser for the next time I comment.
Chat GPT and refactor?
In this post How to generate website using Chat GPT I checked how ChatGPT is doing with generating the layout.
Today, we will see how it copes with the refactoring.
Variables chain
That’s not exactly what I meant.
Let’s try it differently.
Much better.
Complicated LINQ
Okay, time to ask ChatGPT what can we do with this piece of code.
I’m pasting here the code provided by ChatGPT, which allows you to verify that I’m not lying.
This code changes the result. The original code returned 4, but now it’s 20. Tell that to ChatGPT and watch how it will react.
Ok, let’s see.
ChatGPT said that this code would now return 4 as a result, but as you can see, it’s still 20.
My answer for this is
Yes, I know ChatGPT is capable of performing good refactoring, but we still need to double-check everything based on ChatGPT’s answer.
ChatGPT is wonderful tool, but again – it’s not medicine for every problem.
Archives
Understanding K-Nearest-Neighbors (KNN) – Essential Machine Learning Algorithm
2024-10-06A Step-by-Step Guide to Web Scraping for Beginners
2024-07-12Categories
Meta