Earlier, all of my GenAI usage and even now most of my GenAI usage for coding tasks is
related to, you know, fixing certain exceptions by pasting and asking it to address it or
writing small code snippets.
But a couple of months back, I had an opportunity to write core logic for a certain functionality
and I was interested how I can partner, make GenAI my partner in trying to do so.
So let's talk about that particular instance and how that went.
So there's this tool to view Core Web Vitals history on my website again for quite some
time.
What I wanted to add to this particular tool is to show this sort of trend information
as to from when is the performance started to either improve or degrade or a stable basis
this particular data which was already visible.
So my requirement was to use this particular data and kind of get an output of the trend
information and I wanted to write the server side or the core business logic for it and
I thought I'll kind of involve GenAI to do this.
So here's how my cursor prompt for this thing kind of look like.
I have a list of data values with green percentile for different dates as shared in this list.
I'm sharing like I pasted the list below.
How do I go about finding out from what dates major changes in the value started to happen?
I explicitly mentioned I'm not looking for code looking to determine the algorithm to
achieve it and I then pasted the you know array or the list and it got back to me with
the algorithmic approach that it suggested.
You know it asked me to use moving average baseline and then how I can go about detecting
the changes and what should be the chain detection thresholds, this is the values I had provided
and some more information.
It then ran its proposed logic through the list that I had provided and showed me what
the output may kind of look like as to where the change was appearing.
I kind of asked it to make certain more changes to the algorithm.
I also confirmed the threshold values that I wanted and then ran the same proposed change.
This is all in memory so far the algorithm through the same set of values and kind of
told me what the output would look like.
It also showed me you know how the logic was kind of processed through.
So it said like you know basis the logic the major change would occur from November 3rd
for the array that I had provided.
I then went in I asked it to make some more changes eventually I gave it another list
because I now wanted to test how this would fare against some of the other list.
This is all before we've written any code and it kind of got back to me with like its
working logic for this new list I had provided and what would be the output.
I felt some changes and then I kind of requested it to make these additional changes give it
more list for me to do a bit more testing.
It got back to me as to what would be the output with this new list that I had provided
basis all this it looked like you know this is kind of going in a decent direction.
So I eventually asked it to write the code and it got back to me with the code for the
logic that we had devised and at this point I could at least plug in this particular code
to you know see what was the output appearing in this place.
At this point I then went ahead tried to test this with various edge cases wide variation
of values and I made a bunch of tuning fixes modifying the threshold values determining
different cases of it you know so there's a substantial amount of manual tuning that
I ended up doing a lot more testing than I you know would have done and that sort of
thing but it was interesting to have GenAI devised this initial core logic or the basic
logic that allowed me to at least start very rudimentary testing and kind of fine tuning
this with like very large number of URLs and that sort of thing.
So in this way I think I'll kind of start involving GenAI to derive at least the very
initial basic logic which is kind of reversal from the earlier part where I would like write
the logic and then have it kind of plug the you know holes or write the smaller snippets
within that wider logic that I had written.