Hi everyone.
Welcome back.
In this lecture we are going to be coding the similar functionality.
But we are going to be try to implement the same functionality using the coding assistant.
So we hand coded this whole logic right.
And also we ran the program and then validated the program.
Now I'm going to show you one additional approach of coding the same logic using our GitHub copilot.
So in your package.
So if you open the stream Gatherer's package you will see a markdown file over here.
So this markdown file has all the prompts that are required to replicate the code we have been doing
so far.
And I have the prompts available pretty much for all the functionalities that we are going to be exploring
for the stream Gatherer's API.
So in this case, what I'm going to do, let's say you want to do the same coding logic, right?
But you still don't want to hand code it basically the traditional way of coding everything by yourself.
Then what you can do is you can leverage this stream Gatherer's markdown file, and then you can see
that I have a prompt named Windows Fixed Operations certain creating fixed size groups.
So I'll create a table of contents also over here.
There you go.
We have the table of contents.
So it has the windows fixed operations.
If we go to this one it talks about this one right.
So I'm going to be copying this and then open the copilot chat.
I'm not going to use the agent mode.
For now.
Let's use the ask mode.
Let's create a brand new chat.
There you go.
So in here I'm going to be placing this one.
So what is the prompt actually.
So the prompt says that create a method that demonstrates the fixed size windowing of movie collections.
And this is the name of the function it's going to be.
That's the expected function signature.
And then I'm going to be passing these requirements to the LM okay.
So in this case the section header should be windows fixed.
That's what this one is.
Basically this is the print line.
Let me put this in a side by side view and then explain this code okay.
And then what we are doing is that hey the gather that window fixed three to group the movies into windows
of three and process each window as a separate collection and print window contents with proper formatting,
and display each movie with indentation of this one.
Add spacing between windows for clarity, and then handle classes where final window may contain fewer
than three movies.
So here.
This is a very descriptive prompt.
The reason why I'm giving this descriptive is that I would like to have the same code that I have done
to be replicated, but when you are working on some features, let's say you have some thoughts on your
head.
You can actually provide those thoughts in simple manner.
You should still be able to see the similar code replicated for you.
Okay, so now I'm going to pass this prompt and then ask it to write the code for me.
So I'm not doing agent mode, I'm just doing the ask mode okay.
And then press enter.
So here you can see write the same code that we wrote over here is being written for us.
So it says that this is a sysout.
And then we have the gather window fixed of three.
And then you have the whole code being printed in the console after the gatherer gathers the windows
of fixed size three.
And then you can see that.
Here is a quick summary of what's done.
Here we have the group stream into fixed size windows.
Handles the last window gracefully.
And then printing the title over here.
Now you can actually also ask more questions on.
That can you explain more about the windows fixed.
So here it gives you some different examples actually.
So here it gave you a very simple example.
Here we have a list of integers.
And then this is the gather function.
And then this is the output how it's going to be.
And it also talks about what is the key characteristics over here.
And then you can see that with 12 movies how the result is going to be.
And comparison with windows lining is something which we are going to look in the next lecture.
But this is a beauty of this coding assistant.
Now what I'm going to do is that I'm going to remove this whole code.
Okay.
Now I'm going to ask the agent to make the change for me.
So now I'm going to go to the agent mode.
Can you please make the change in the demo dot Java file, please use the initial code that you generated
for movies.
So I'm going to press enter.
Okay.
So this is an agent mode which is going to go to this file and then make the change for you.
You'll be able to see it as it's doing the changes.
So let me close this one open so you can see that it is going to be starting to edit.
You see this right.
It edited the file for you.
So here we have the similar code which is movie stream gather for each.
It's the same code that we wrote beforehand.
Now you have this code readily available.
All you got to do is give this prompt and it will write the code for you.
Let's say if you are really lazy to type in, but you still understand the complete concept, if you
want the AA to do the for you, it will very much do the job for you without any issues.
Now what I'm going to do, I'm going to be accepting this change, and then I'm going to run the program
again, and then I'll show you the result.
There you go.
It's the same result that we have over here.
So this is the beauty of these copilot assistant where you don't have to hard code everything.
All you got to do is provide a proper prompt.
It will write the code for you without any issues.
And this also improves our speed of learning.
And also from a developer standpoint, all you got to do is you ask the prompt, the LM will write the
code for you.
You will be like a human in the loop who validates the code is good or bad.
If the code generated is not aligned to what you are thinking, all you got to do is give it a feedback.
It will make the changes for you.
So in the following lectures I'll be hand coding this stream gatherer API concepts.
But this is something which I would like to show you as a modern way of learning things.
Modern way of coding concepts.
Modern way of building applications.
Using these AI assistants, these AI assistants are going to stay and it's going to continuously get
better.
I hope you all were able to successfully code this windows fixed concept using the AI assistant.
And in your case, all these concepts will be available as part of these prompts.
Um, please go ahead and start using these concepts of using AI assistant to write the code for you,
which is again going to improve the developers productivity and also the speed of learning as you learn
new concepts.
This marks the end of this lecture.
Thank you for watching.