Read the original blog post here:
https://beyondbinary.dev/posts/ask-gpt-before-seniors
ChatGPT is an excellent tool for software developers if used properly.
I wish ChatGPT had been available when I was a junior developer. I didn’t have any senior developers available, so I had to Google my way out of questions, issues and new concepts. I did get extremely good at searching, however, I think most developers are excellent searchers. During my time as a senior developer, I have seen some of the common questions and issues that arise for junior developers. Most of the time, they’re simply related to not having been exposed to the various concepts and programming methods. As Socrates said:
You don't know what you don't know
— Socrates
This is where ChatGPT might become your own personal senior mentor, opening doors to new concepts, and you are able to ask an endless amount of questions without it getting annoyed. I want to tell you about how I think junior developers can leverage ChatGPT to grow as a developer.
Important note: Never ever put any company related information into ChatGPT.
So how can I use ChatGPT to grow as a developer?
I use ChatGPT daily, even as a senior developer. It helps me do a lot of mundane tasks, planning, and optimizing the solutions that I have done. It helps me brainstorm on solutions that I can use in discussions with other developers. It provides me with possible solutions faster than I would have gathered on my own.
The concrete example is for PostgreSQL but the concept can apply to all technologies, both backend and frontend.
To give an example of a prompt that I might use when doing database queries.
Note: Tables and query are just examples to force ChatGPT to give some relevant answers. They are not production-ready.
Start by setting the scene of how it should act. You find the complete prompt below the prompt sections.
Act as an expert database administrator.
Explain in simple terms the changes and why you have made them.
Then give it context of the related schemas:
I have these two schemas:
CREATE TABLE users (
id SERIAL NOT NULL PRIMARY,
name TEXT NOT NULL,
email TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE tasks (
id SERIAL NOT NULL PRIMARY,
title TEXT NOT NULL,
description TEXT NOT NULL,
assignee_id INT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
And, finally ask how you could optimize your query.
Given the above schemas,
how can I optimize this query for getting the total of tasks per user?
SELECT
users.id,
users.name,
users.email,
COUNT(tasks) AS total_tasks
FROM
users
LEFT JOIN tasks ON tasks.assignee_id = users.id
GROUP BY
users.id;
Let's see what ChatGPT answers.
We got an excellent response on how we could improve our query and our database schema. ChatGPT will even tell you why a change might make sense.
In this example, it's quite obvious that we need an index
(or foreign key
) on our assignee_id
column in our tasks
table.
Another subtle change in the GROUP BY
is another thing that a junior might not have caught before submitting a Pull Request. By applying these changes, you avoid having your colleagues point these things out. You appear more experienced and you have learned a ton in the process.
Finally, we can ask ChatGPT to improve our existing schema both as an exercise to learn more about the schema and how we might improve it. You can use the concepts that ChatGPT mentions to do your own research which makes the conversation with a senior developer more informed.
ChatGPT provides a quite lengthy response but you get the idea.
These kind of answers are invaluable as a junior since ChatGPT will provide tons of concepts that you might never have heard of. You get the chance to ask questions like What's a foreign key?
, Can you explain JOINS?
etc. You can literally ask ChatGPT anything.
Limitations of your ChatGPT mentor
The data that ChatGPT is trained upon is a few years old, at the time of writing, it's from 2021
. The answers given are very much related to the question. If you formulate the question in a certain way, you can get a wrong answer. Don't trust the answer blindly, always be critical before applying any changes that ChatGPT has suggested. Do your own research if you are uncertain.
Never ever put any company related information into ChatGPT.
Code snippets, table definitions etc., are fine in isolation because it doesn't provide the greater context. This is where ChatGPT has it limitations. It will never understand the entire scope of the code that you are working with. Therefore, you must always be aware of the limitations before following suggestions.
Conclusion
ChatGPT can help you grow as a junior developer because you are able to ask it any question you might have. It's not limited to the senior knowledge and in case you don't have any seniors available, it can replace some of the benefits. It will, however, never replace a human being explaining concepts tailored to you. If you have a senior colleague, they will also have the context of the company and will be able to give better answers specific to the company.
Top comments (0)