Photo by Possessed Photography on Unsplash
ChatGPT, a natural language tool created by OpenAI, can be a great ally for software engineering professionals who want to improve their skills. This article will show some practical examples of using ChatGPT to help with software development. With its ease of use and customization features, ChatGPT can contribute to improving the performance of software engineers.
Accessing the ChatGPT
Go to https://chat.openai.com/chat and create an account. You can use a username and password or your Google or Microsoft account.
How it looks like
This account will preserve the history of your conversations so you can access them later in another session. However, it is also possible to delete the history of a conversation or several, as you prefer.
Questions and answers
To use ChatGPT efficiently, it is important to formulate clear and objective questions using the appropriate terminology for the area of programming in question. Assessing the relevance and applicability of the results obtained is recommended, as checking whether the question asked makes sense.
Keep in mind that ChatGPT also speaks in several languages, which makes it easier if you are not comfortable with English.
Question is the key
Unlike other search engines where we enter keywords, in ChatGPT, you can ask questions as if you were talking to someone. Be sure to include as much detailed information as possible.
Avoid asking subjective, vague, or broad questions. For example, if you ask how to create a registration screen from scratch, the result will probably be how to start an Android project and create components like XML, which is very vague and equally broad.
Therefore, it is preferable to ask specific questions about what you want, mentioning details. Don’t hesitate to be verbose. The more information, the more accurate the answer will be. In the example below, I give details of the technology and what I expect.
The result is Jetpack Compose code, which is likely ready to be added to your Android project. Now that you’ve asked the right questions, the next hurdle is interpreting the answers.
Does the answer help me?
In a search engine result, you will see an ad at the top, followed by a sponsored post and the first result of your search. So you open the first link and read the content. Not what you are looking for? Don’t worry! There are hundreds of thousands of pages of results where you must look for what you need.
Unlike the scenario above, ChatGPT will give you a right or wrong answer. This is the challenge because he won’t say he doesn’t know something. It will simply give you an answer! Therefore, the interpretation and testing of the solution to your proposals are fundamental!
Imagem do post https://www.linkedin.com/pulse/high-time-take-chatgpt-offline-aleksandr-tiulkanov/
If ChatGPT does not answer you correctly or completely, feel free to ask again, giving more information about what you seek. ChatGPT maintains context between questions, so it knows what you’re discussing.
For example, ask ChatGPT to rewrite the above code, changing the variables to firstName to completeName. The same code but with new changes.
As seen above, ChatGPT is a versatile tool that can help in many areas, including code generation.
Although it cannot create an entire structure or all the code of an application, the user can break a big problem into smaller problems and, with ChatGPT, have the necessary help. How to create specific task roles.
In addition to providing the code, ChatGPT can also explain how this code works, which can help you better understand what is being done. It is important to carefully evaluate all responses received and, if necessary, request changes that meet your needs or change them yourself.
By copying a code snippet and asking ChatGPT if it contains any bugs or errors, you can get feedback on code quality and identify potential issues. ChatGPT can offer suggestions to fix the code, improve efficiency, and avoid common errors. This can save time and effort when debugging and testing code, helping developers build more reliable and efficient software.
If there are code improvements, ChatGPT will provide explanations of what might be going wrong and offer suggestions for resolving the issue.
⚠️ Be careful about sharing code⚠️
The code is the intellectual property of the company, not the employee. Sharing it with ChatGPT without prior permission may be a breach of contract.
Besides that, the AI can access and store this sensitive information. If multiple employees have access to the tool, they could inadvertently share this information, leading to security breaches and other serious consequences.
If hackers compromise the tool, company information could also be exposed. So, it is important to carefully consider the risks before sharing sensitive information with ChatGPT or any other AI tool.
You can also copy some code and ask ChatGPT if it can generate a unit test to validate your function. ChatGPT can walk you through best practices for unit testing and suggest how to structure your code to make testing easier.
Again, it will return the unit test code and explain how the test was done.
ChatGPT is also capable of helping to generate documentation for the presented code.
As shown above, we can specify the language and rules, like the character limit per line in the code.
ChatGPT can help you understand how a code works if you need a more detailed explanation.
Don’t hesitate to ask questions about concepts, architectures, tools, or ordinary things that might come to your workday.
In fact, we can ask about anything, but the focus of this post is to show how ChatGPT can help software engineers.
Prepare for interviews/selective processes
ChatGPT can also be a powerful tool for job seekers. Here you can ask how to prepare frequently asked questions or common interview challenges. Be creative and use it to be more prepared for your interviews.
Again, always keep in mind the reliability of ChatGPT. In the example above, It appears questions about Android components that could be uncommon nowadays, like AsyncTask, LinearLayout, and RelativeLayout. Always evaluate the result.
ChatGPT helps with developer productivity, but it’s important to consider its limitations.
Slowness and instability
The free version can be slow and unavailable if many people are accessing ChatGPT at the moment, which requires the user to refresh the page manually to try their luck.
Premium (and paid) version
To have faster responses and not count on unavailability in case of many accesses, ChatGPT offers a paid version for 20 US dollars per month. It is worth mentioning that nothing guarantees that the free version will continue to exist in the future.
As stated earlier, ChatGPT will answer anything, right or wrong. Assessing the response is critical. Even with your experience, you can overlook errors proposed by ChatGPT, so use it as a co-pilot, where you have creative control of solutions and decision-making.
ChatGPT is an AI trained on a pool of information, and this training is less constant nowadays. For example, it might not have the latest Kotlin or Android updates or recent events like the latest Google IO.
As a basis, as of the date this post is being written, March 2023, your last free version training is September 2021.
It’s currently impossible to upload files, so you’ll have to copy code snippets if you want reviews. The tool is limited to 1000 characters max per question.
It’s also impossible to format code using quotes, as in Markdown or Slack. Then the developer will have to send it as a text message.
ChatGPT is an OpenAI tool that uses information on the internet to feed its database, including what is sent in conversation with ChatGPT. Therefore, it is important to avoid sharing confidential information.
As we’ve seen, ChatGPT has the potential to revolutionize the way developers work. Although there are some reliability, speed, and up-to-date information limitations, ChatGPT can be a strong ally in increasing productivity and optimizing development time.
No need to worry about ChatGPT stealing jobs. On the contrary, the tool can be seen as a valuable support, capable of making developers’ routines more efficient and free of repetitive and tedious tasks. Combining artificial intelligence with human creativity and skill, we can look forward to a more promising and productive future for software engineering professionals.
You can find me on Twitter at @orafaaraujo.
Feedback is welcome!
This article was previously published on proandroiddev.com