Cleverly use GitHub Copilot to increase productivity - Part 2

By using AI code assistants, the key to success lies in the interactions between the tool and the programmer. As the name implies, the "assistants" are there to take instructions and convert them into workable code for you. For this to happen, you have to know what needs to be coded in the first place.

Credits: DALL-E

This article is the first part of a two part article about using Copilot to increase productivity. You can view the first part here

Coders are passionate and often strive to accomplish a challenge given to them. Over the years, I've seen countless programmers receiving a challenge and then jumping head first into their editor, coding right off the bat just to realize they've been building in the wrong direction. They then have to readjust along the way while trying to salvage what could be used. This is the perfect recipe for what we call a spaghetti (or at least time loss).

Knowing ahead of time what needs to be done is a crucial part of the success of a product. Planning not only establishes the right path to take, it also helps avoid possible pitfalls along the way. It's even more true when using a coding assistant. Since it waits to receive hints on what to produce, knowledge of the situation must be passed along in a comprehensible way. By planning ahead of time, providing those hints gets much easier.

The important point here is to get to “know” the code before coding. Be careful not to over-plan things. The aim is to reach the sweet spot between knowledge and time consumption, finding the right strategy for a given situation. Let's take a look at some simple steps for solving this problem.

Define the requirements

Clearly identify what needs to be done and what is required to achieve that goal. Gather all necessary requirements from stakeholders or project documentation, then break them down into a list of manageable pieces. It will give you an overview of the important parts, making sure everything is implemented as intended.

Create a diagram

This is where it could get tricky. Some engineers swear by UML standard diagrams and will praise their benefits. They are indeed useful but can quickly become cumbersome because they can quickly become complicated to implement properly. The key here is to create something that visually represents what needs to be done. It could be a flow chart, class diagram or a simple linking of boxes. As long as it gives the right information without being too restrictive, it’s all the better. Go with something you feel comfortable with.

List functionalities

When working on small to medium tasks, it can be useful to write a listing of functionalities required to fulfill the requirements defined in a prior step. The listing, accompanied with a descriptive statement, is useful to grasp the overall structure of the code. Those functionalities can easily be grouped in classes or modules then broken down into smaller pieces. It acts as some sort of checklist providing the direction to take when implementing them.

Write pseudo-code (optional)

Aimed at breaking down complicated functionalities, pseudo-code helps put on paper what logically needs to be done. By using a coding assistant, this step is less important as the practical logic will be laid out by the tool. To be time efficient, the pseudo-code needs to be written as a summary where an artificial intelligence has enough information to come up with its own implementation.

More context

With knowledge in hand, the next step is to transfer the information to the AI assistant. It must be explained in a comprehensive way to have it generate the expected implementation. This passing of information can be done through comments left across the code. The more context given, the better the quality of the generated code. Always try to provide some, if possible.

For example, the following code:

$list = $gradeModule->getList()

//Create a function where it calculates the average grade percent in the list of grades

Could be transformed into this:

//Every item of the list is a GradeResult object with the getPercent() method
// that outputs a grade percentage (between 0 and 1) assigned to students
$list = $gradeModule->getList()

//Create a function where it calculates the average grade percent

The assistant would know what each item of the list consists of and that the getPercent method needs to be called in order to calculate the average. With this added context, there is a higher chance it will produce the proper implementation of the average function.

Closing thoughts

Artificial intelligence has opened the way for assistants in many ways. By analyzing the vast sea of code, openly available through open-source projects, they became very dependable companions, greatly increasing productivity of the ones using them. Be warned that generated code should always be reviewed thoroughly in order to prevent mistakes, harmful implementations, or the inclusion of copyrighted content, making sure the quality is on par with what could be done by a human mind.

Possibilities are endless but remember, creativity is the key.

Disclaimer: No AI models were used in the writing of this article. The text content was purely written by hand by its author. Human generated content still has its place in the world and must continue to live on. Only the image was generated using an AI model.

Articles you might be interested

Cleverly use GitHub Copilot to increase productivity - Part 1

It was only a matter of time before artificial intelligence technology’s power was to be harnessed towards processing programmable language. The log ical reasoning of AI mixed with the immense pool of open source examples paved the way to the creation of the first stepping stone in an automated digital product creation environment.

March 24, 2024

Cleverly use GitHub Copilot to increase productivity - Part 1

It was only a matter of time before artificial intelligence technology’s power was to be harnessed towards processing programmable language. The log ical reasoning of AI mixed with the immense pool of open source examples paved the way to the creation of the first stepping stone in an automated digital product creation environment.

March 24, 2024

Cleverly use GitHub Copilot to increase productivity - Part 1

It was only a matter of time before artificial intelligence technology’s power was to be harnessed towards processing programmable language. The log ical reasoning of AI mixed with the immense pool of open source examples paved the way to the creation of the first stepping stone in an automated digital product creation environment.

March 24, 2024