Programming with AI: Breaking Free of Dogmas
I wrote about programming dogmas before and when programming with Generative Artificial Intelligence, or I’ll just say: AI, I realize:
AI can do all the programming dogmas in a second
One of the biggest ones I have is to always test your code. I believe writing tests first is the best way to write code. So much that I’m a devout practioner of test driven development, TDD.
Until now.
With AI, why even write tests? You can take all the code you wrote, put it into the AI, and prompt:
Write tests for this code
The AI will generate tests for your code.
It’s magical ✨
Like seriously, getting me to practice TDD took so expensive lessons that are difficult to teach others.
Here, AI does the test writing part in an instant?!
Guess how I will be programming next?!
WITH AN AI!
The same goes for other programming dogmas:
Example Prompt | |
---|---|
1. Always test your code | Write tests for this code |
2. DRY: Don’t Repeat Yourself | Rewrite so function x is only used once |
3. Document your code | Write documentation for this code |
4. Abstractions | Refactor this code to use better abstractions |
5. A function should do only one thing | Refactor this function into multiple smaller functions |
6. Have good variable and function names | Rename “this” to “that” |
With AI, programming dogmas, best practices are just a prompt
away and let programmers focus on:
Solving problems
Instead of solving the problem of making their solution conform to “programming best practices”.
Programming becomes…fun again!