AI Is Changing The Way We Code: AI-Driven Development (AIDD)

These days, it appears that anyone can write code. You’ve probably seen plenty of videos online of non-developers using AI to generate working scripts in no time. Code that actually seems to work! It’s like magic.

And it is kind of like magic. These n…


This content originally appeared on DEV Community and was authored by Dawid Dahl

These days, it appears that anyone can write code. You’ve probably seen plenty of videos online of non-developers using AI to generate working scripts in no time. Code that actually seems to work! It’s like magic.

And it is kind of like magic. These next-generation models like ChatGPT emerged onto the scene in 2023 and blew almost everyone’s minds; even non-technical people were amazed by all the things AI could do, coding being just one of them.

And not only that, it is getting better and smarter by the month. The pace of improvement is absolutely astounding. It seems everything is about to change.

It's a Br-AI-ve New World

But wait… doesn’t that mean developers are about to be replaced by AI?

Surely if grandma can now divide-and-conquer a data structure using an AI-generated merge sort algorithm in O(log n) time without breaking a sweat, how could it not mean exactly that?

Maybe it’d be smart to start looking elsewhere for work. How about Gardening? Plumbing? Yoga instructor influencer? Anywhere where we might shield ourselves from this sudden AI disruption.

Well, hold on just a moment. In this new world, code can indeed be generated by AI. Great code, too. But here’s the kicker: how can we gain confidence that this code will actually do what it is supposed to do, in a good way, and in an ever-changing environment? Especially within the context of a software system consisting of other AI-generated code, with which it is going to have to integrate.

How can we as developers harness and benefit from the vast intelligence of these new AI companions, while also ensuring that our customers’ complex software systems remain maintainable, scale well, and function without bugs?

That is the problem that AIDD solves.

In this article and its accompanied video, we'll explore the eight core steps of AI-Driven Development and see how this workflow could have the potential to supercharge your life as a developer. And how it does so not by fighting against—nor surrendering—to the AI, but by joining forces with them.

The Value Of Human Development Skills

But before we do, for the developers out there who might still be concerned about the rise of Artificial Intelligence and how it might affect their job security.

What exactly are the reasons why your skills and creativity as a developer will remain crucial to the software construction process?

Here are just five of the many exciting responsibilities you can expect as a future AIDD developer. Some you will be familiar with, some are brand new.

  1. Be the one who has a deep and thorough understanding of the vast space of vague human customer requirements.

  2. Carefully guide the AI through the AIDD process.

  3. Create your application’s testing pyramid. From unit to integration to E2E tests. Yes, the AI can and will help you out here, but you are ultimately responsible for the health and maintenance of the test suite.

    Testing pyramid

  4. Repair and modify systems built using AIDD.

  5. Use your skills as a developer to make sure the system fulfils customer requirements while also respecting the many principles of professional software construction:

  • Correct (vs buggy, crashing, doing nothing, or not executing)
  • Stable (vs brittle, or non-deterministic)
  • Readable (vs unreadable, or obfuscating)
  • Testable (vs tightly coupled)
  • Scalable (vs tightly coupled)
  • Extensible (vs tightly coupled)
  • Flexible (vs tightly coupled)
  • Reusable (vs tightly coupled)
  • Cohesive (vs low cohesion)
  • Maintainable (vs not DRY, no documentation, dead code, etc)
  • Performant (vs slow)
  • Secure (vs insecure)
  • Usable (vs frustrating user experience)
  • Accessible (vs only for privileged users)
  • Portable (vs tightly coupled to specific medium)
  • Minimal (vs over-engineered)  


These five competencies—dealing with human customers and their ambiguous requirements, AI guidance, test suite creation/maintenance, repair/modification of AI-created systems, wisdom of high-level software principles—are just some of the reasons why you will still be valuable in the workplace as a developer.

For the foreseeable future, it is reasonable to assume that many of these skills won’t be taken over by AI.

So What Is AI-Driven Development?

AIDD follows the 'red, green, refactor' cycle, just like Test-Driven Development (TDD). It also employs the technique of writing tests before implementation code. In a way, we can say that AIDD is like a futuristic extension of TDD.

However, unlike in traditional TDD where developers are responsible for creating both unit tests and implementation code on their own, AIDD introduces a new approach, emphasizing deep AI teamwork.

Red, Green, Refactor Cycle

Employing the AIDD technique, you are no longer working alone; you have a smart and patient AI ally by your side, ready to come to your aid at almost every stage of development. Instead of you doing the heavy lifting, your AI companion goes to work behind the scenes while you can focus on higher-level development tasks.

The 8 Steps of AIDD

To demo the technique, let’s first go through the steps at a general level. After that, in a video we’ll go concrete with a simple yet practical example, where we construct an isolated function to achieve some goal.

This way, you will start to get a feel for how this process works, and how it can really empower you in delivering value to your customers.

1: Set the goal

Think about the function at an extremely high level; what are you trying to achieve? Consider it only in terms of Input→Output.

☝🏻 Reflect on the function’s API, the ergonomics of actually using the function. Specifically, how many and what kind of arguments should it take? Should they be optional or not? Etc.

2: Formulate the abstract type

Use a strongly-typed language—TypeScript, C#, Haskell—whatever you are using in your project, to manually write the type or interface for the function's input and the output. Strive always for pure functions, unless you have absolutely no choice but to cause side effects.

☝🏻 If you need help in this or any other step, as always—ask the AI.

3: Construct mock functionality

Using the function type you made, give them to the AI and ask it to construct a mock function. This is a function without an implementation; it simply simulates a real function by faking the output.

4: Write tests

Ask the AI to create unit tests for this yet-non-existent-function, as many as you need, based on the function type and a description of what you are trying to achieve.

Carefully review the tests it creates. If necessary, add more manually, until you get the feeling that if these tests pass, you will actually feel confident in the function’s correctness.

Here's another possible way to do step 4: write all the tests yourself, but with only one assertion for each test case. Then, you can ask the AI to generate 5, 10, 20 more similar assertions for each.

With more assertions per unique test case, the probability of the function passing the test by sheer luck decreases.

☝🏻 The unit tests should be lightning fast. This is achieved by not relying on any external state or circumstance, employing techniques like the heavy use of pure functions, monads like Promise or Maybe, dependency injection, mocking, etc.

5: Run tests and expect failure ❌

Run the tests using the mocked function and watch them dramatically fail.

If the majority of the tests are not failing—some probably will pass due to luck—return to step 4 and rewrite the tests to be more comprehensive and all-encompassing.

6: Create concrete implementation

Now finally, it’s time for the magical last step of TDD and AIDD: the refactoring. It is here we actually create and then improve on the function.

Give the AI the types or types you made in step 2. Or give it a simple verbal explanation. Or even all the unit tests you made. And unleash it!

7: Run tests and expect success ✅

Use the function it creates and, hopefully, watch them gloriously pass!

If they don't—which will probably happen quite frequently, at least now in 2023—collaborate with the AI to achieve the goal of the tests passing. You could:

  • Ask the AI to try again, supplying any error messages and ideas you might have to help it out.

Or:

  • Manually review the function and see if you can fix it, or implement it yourself. Ask the AI for ideas to help you out.

8: Refactor

Once all the tests have passed, it's important to review the function manually and assess whether it aligns with the spirit of professional software construction mentioned earlier. If not, maybe consider refactoring the function.

☝🏻 Again, if you're still not sure why you won't be replaced by AI anytime soon, the step above is one of the main reasons.

If the tests start to fail during the refactoring process, keep collaborating with the AI, following the same approach as in step 7, until all the tests pass again.

(Optional Final Step): Celebrate!

All done! Congratulate yourself and celebrate the fact that you are now one step closer to delivering happiness to your customer! 🎉

☝🏻 In this article we are focusing on unit testing. However, I believe that in general AIDD is applicable to the other testing strategies as well. That said, it should be acknowledged that these other tests typically cover more complex scenarios and therefore require further manual effort and careful thought from the developer.
☝🏻 Although the principles of TDD and AIDD are close to identical, it's not until you start developing that you begin to see the significant differences between the two approaches.

AI-Driven Development in the Wild

Finally, let’s see an actual example of how AIDD can be used in the real world.

Why not attempt to follow along with your own AI companion?

If you did follow along with the video, just pause for just a moment and take in the fact you didn’t actually create that function yourself. You didn’t even create all the unit tests yourself!

Instead, you were like a god; guiding your creation with subtle nudges—yet never directly intervening.

That, at least to me, is mind-blowing.

Dawid Dahl is a full-stack developer at UMAINARC. In his free time, he enjoys philosophy, analog synthesizers, consciousness, and being with friends and family.

Credit for pyramid and cycle graphics: Jenny Eckerud.
TS/Jest CodeSandbox template used in the video.


This content originally appeared on DEV Community and was authored by Dawid Dahl


Print Share Comment Cite Upload Translate Updates
APA

Dawid Dahl | Sciencx (2023-03-09T07:49:32+00:00) AI Is Changing The Way We Code: AI-Driven Development (AIDD). Retrieved from https://www.scien.cx/2023/03/09/ai-is-changing-the-way-we-code-ai-driven-development-aidd/

MLA
" » AI Is Changing The Way We Code: AI-Driven Development (AIDD)." Dawid Dahl | Sciencx - Thursday March 9, 2023, https://www.scien.cx/2023/03/09/ai-is-changing-the-way-we-code-ai-driven-development-aidd/
HARVARD
Dawid Dahl | Sciencx Thursday March 9, 2023 » AI Is Changing The Way We Code: AI-Driven Development (AIDD)., viewed ,<https://www.scien.cx/2023/03/09/ai-is-changing-the-way-we-code-ai-driven-development-aidd/>
VANCOUVER
Dawid Dahl | Sciencx - » AI Is Changing The Way We Code: AI-Driven Development (AIDD). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/03/09/ai-is-changing-the-way-we-code-ai-driven-development-aidd/
CHICAGO
" » AI Is Changing The Way We Code: AI-Driven Development (AIDD)." Dawid Dahl | Sciencx - Accessed . https://www.scien.cx/2023/03/09/ai-is-changing-the-way-we-code-ai-driven-development-aidd/
IEEE
" » AI Is Changing The Way We Code: AI-Driven Development (AIDD)." Dawid Dahl | Sciencx [Online]. Available: https://www.scien.cx/2023/03/09/ai-is-changing-the-way-we-code-ai-driven-development-aidd/. [Accessed: ]
rf:citation
» AI Is Changing The Way We Code: AI-Driven Development (AIDD) | Dawid Dahl | Sciencx | https://www.scien.cx/2023/03/09/ai-is-changing-the-way-we-code-ai-driven-development-aidd/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.