........ Disclamer: Please note that I am not a lawyer. All the information provided here related to how I've integrated ChatGPT into my workflow should be considered with caution. It is important to use your own judgement when dealing with matters related to licensing, copyright, and other legal issues. I am simply sharing my experience and approach, and ultimately, it is up to you to make your own informed decisions when it comes to copyright and legal stuff.
Not all things listed here are my creation. I'm sure I've read all of these somewhere on the Internet, and later on I've integrated them into my flow. I did my best to credit the original posters whenever I still remembered the article where I originally read it.
ChatGPT is a fantastic tool to use as a software developer. There are scenarios when I'm like two times more efficient working along ChatGPT than I would have been doing the same task alone. Writing a "hello world" app when starting with a new technology, getting started on a task I never did before, brainstorming a hard problem, comparing different approaches, preparing for an interview, these are the kind of scenarios when I find ChatGPT very very useful.
There are however few rules I always have in place when using ChatGPT:
I never provide code that belongs to the companies I'm working for (and thus is protected by copyright) to ChatGPT. It's very tempting to ask ChatGPT for a code review (and it does this very well!) or to ask it to figure out bugs in my code (it's also very good at this), but thing is I never know what ChatGPT is going to do with my code. It might as well provide the commercial code belonging to the company I'm working for to another developer asking for an answer. As long as the code does not fully belongs to me (as in my hobby project) but belongs to the company I'm working for, I will never share it with ChatGPT.
I never copy paste code generated by ChatGPT into commercial projects. I can never be sure that the code ChatGPT provides is not copied from a GPL licensed project. And nobody can be sure of that, even the OpenAI team cannot guarantee that. There is a single exception to this rule, when it's obvious that the code is some very basic code, like a "hello world" fragment. Check this article for a more in-depth analysis. It's about image generation, but I think it applies to ChatGPT as well.
I never use code generated by ChatGPT that I don't understand. ChatGPT can be really confident, even when it is completely wrong (see this post). I never take it for granted.
1. Getting started on a task you never did before
Few days ago I had to invoke a SOAP endpoint using Python. Last time I used SOAP it was like 10 years ago, using Java and Axis. I could of course google it, read some docs, copy paste some getting started code from the docs, you know, the ancient approach. Instead, I did this:
Should I go for Zeep, or choose one of the other two ? I could go to StackOverflow and read a few posts, or I could do it like this:
Less than one minute and I have all I need. Then I continued asking on how to do authentication, how to do a call, how to handle exceptions, whether it's thread safe or not. It performed very well.
2. Architecture brainstorming
I did that a few times as an exercise. It's really enjoyable to talk to someone (yeah, I feel it like a real human colleague when working with it) who knows a lot of things (way more than I do) and has a good ability to reason (or at least, it feels like it). I've written a post on working with ChatGPT to design a software system similar to Whatsapp here, feel free to check it. I did learn a few things. I was not aware there are so many options when it comes to message bus implementations in Azure. After things were ready to a certain degree, I asked it to migrate to AWS from Azure. And he did it. For me, I find this a great learning experience. Instead of reading docs, I do some hands on design exercise and at the same time learn new things. It can even generate diagrams (to a certain degree).
3. Translate code from one language to another
Easy, right ?
And some ancient stuff.
Even ChatGPT has its limits:
4. Exploring cloud services
I used the AWS cloud a bit, few years ago. Obviously, I forgot a lot of things. I decided to see how easy it is to deploy a ReactJS webapp with a lambda serverless function as backend and DynamoDB as the persistence layer. I might have took me like a day to finish this alone. I did it in two hours with ChatGPT. It simply tells you what do to and where to click. The
whole journey is here.
5. Solve programming challenges as interview preparation
You know those programming challenges Google, Amazon and alike use for the interview. They are hard. Even understanding the solution posted on some website can be hard sometimes. Well, asking ChatGPT to solve these for you it's way easier. You can ask it to detail things further whenever you don't get it the first time.
Not familiar with DFS ? That's fine.
6. Prepare for an interview
Use a prompt as this one and have fun during your interview.
I want you to act as an interviewer. I will be the candidate and you will ask me the interview questions for the position _position_. I want you to only reply as the interviewer. Do not write all the conservation at once. I want you to only do the interview with me. Ask me the questions and wait for my answers. Do not write explanations. Ask me the questions one by one like an interviewer does and wait for my answers. My first sentence is "Hi"
Funny how it helps me with a more appropriate answer than my dry "yes" reply.
7. Investigate errors
Not the best use case (sometimes Google and StackOverflow still works better for me), but still amazing nevertheless. You can see this use case in
this post. Whenever things were not working for me, I simply copy pasted the error. And sometimes it nailed it. It's really nice it provides a custom solution, tailored specifically for your needs. Below, it gives me the policy I need to use. Not some generic policy for me to adapt, but exactly the one I need for my project.
Make sure you understand the solution before using this in a project you care about ! As I've also warned at the start of this post, sometimes ChatGPT tone is really confident, even if the solution is wrong.
Never take it for granted for important matters ! 7. Summarise an article
Sometimes I don't want to read a 20 page article, I just want a summary. ChatGPT is good at this. The only drawback is that you have to manually copy paste the content, and sometimes it might be too large for it to fit in one pass. Here's a summary for
this article:
Warning: as you can imagine, both tools require access to read the data from any website you open in Chrome in order to perform their task. I was not comfortable to grant them permission. Use your own judgement here.
There even a
tool for Youtube videos. Could not test it myself, it says "server too busy" all the times I've tried.
8. Write a whole application from scratch
Even it's spectacular, I did not start with this because I feel there are very little scenarios that ChatGPT can handle on its own for the time being. But when it can do that, it's spectacular !
I did an experiment copy pasting the whole Midjourney user manual to ChatGPT and asking it to build a frontend app to make Midjourney easier to use. And it did just that. You can test the application here .
The whole experiment is documented in
this blog post. I still find it very painful how long it takes to write code. I guess that this is linked to how it works internally. It's not pleasant to wait for 2 minutes for it to type two screens of code. I just asked it to give me the diffs and I applied these manually on the code base. A bit more simple.
9. Generate regexp
Admit it, you hate regexp. I hate regexp. We all hate regexp. Still, we use them. ChatGPT can ease the pain a bit.
10. Explain spaghetti code
Warning: this is a scenario where you might be tempted to paste code from your commercial application to ChatGPT. Don't, unless you fully consider the implications. As long as I'm concerned, I choose to never do that except for when I'm working on hobby or opensource projects.
Can you understand this Python code ? I can't.
- (lambda f: f(f, 1))(lambda f, n: None if n > 100 else print((not n % 3 and "fizz" or "") + (not n % 5 and "buzz" or "") or n) or f(f, n+1))
Well, bad luck ! ChatGPT understands it and it can explain as detailed as you need:
It even has the courtesy to refactor the code so that my simple human mind can comprehend it.
11. Generate unit tests
Warning: that's another scenario where you might be tempted to paste code from your commercial application to ChatGPT. Don't, unless you fully consider the implications. As long as I'm concerned, I choose to never do that except for when I'm working on hobby or opensource projects.
I want you to stop reading and try to come up with some unit tests on your own before continuing. Don't write the code, just think of what you are going to test.
I admit I would never ever consider the edge cases ChatGPT came up with:
I will use this opportunity to ilustrate how easy is to be tricked to take for granted what ChatGPT says, even when it's wrong. He's so confident, and provides so many amazing solutions so it's easy to miss the error here:
In Python, adding an int to a string via the addition operator fails with error. That test is wrong.
Let's see if it can fix it alone:
12. Code review and improve code quality
Warning: yet another scenario where you might be tempted to paste code from your commercial application to ChatGPT. Don't, unless you fully consider the implications. As long as I'm concerned, I choose to never do that except for when I'm working on hobby or opensource projects.
Here's some dummy code for ChatGPT to improve:
As long as you remember to never provide commercial project code to ChatGPT (you never know how is going to use it), you don't include code generated by ChatGPT into your commercial project (it might be code copied from a GPL project) and you don't take for granted everything it gives you, I find ChatGPT to be a fantastic companion while writing code.
Comments
Post a Comment