Empowering Digital Product Leaders
meatburger is better than veggie
Coding with AI: Best Practices for Digital Product Teams

Coding with AI: Best Practices for Digital Product Teams

  • Product Development /

As a digital product leader, you focus on accelerating product delivery and development velocity. AI coding assistants like GitHub Copilot and Tabnine promise to do just that by acting as virtual pair programmers for your engineers. These tools suggest full code blocks on the fly, boosting productivity.

Backed by deep learning trained on public code, Copilot and similar AI tools adapt to your team’s style and improve over time. They’re intended to reduce the grunt work of writing repetitive code across languages like JavaScript, Python, and more. But they aren’t a replacement for the critical problem solving skills developers bring to building scalable products. 

While AI coder augmentation speeds output, irresponsible use risks accumulating technical debt. Seamlessly integrating auto-generated code requires diligence and governance.

This article will cover techniques for product teams to leverage AI programmer partners responsibly. We’ll provide guidance on integrating Copilot-style outputs into your codebase sustainably. With the right oversight, AI pair programmers can supercharge workflow without compromising long-term agility.

Tabnine demo video
Demo of Tabnine generating code

The Promise and Pitfalls of AI-Generated Code

AI coding tools offer an alluring productivity boost by automatically generating code. But as Brenna Switzer, Emerge’s Director of Engineering, cautions, integrating machine-written code comes with tradeoffs.

On the positive side, AI can rapidly produce functional code for rudimentary tasks. As Brenna explains, “Machine generated or AI generated code, is generated meaning. It’s essentially single use…it often gets the job done, or at least close enough that you can do it.” This allows developers to avoid repetitive coding for simple needs.

However, Brenna notes AI code lacks the flexibility and readability needed for ongoing maintenance and scaling. She states: “You get functionality without flexibility. So it’s really great for short-term. You can get it done quickly.” Unlike human developers, AI lacks insight into long-term business needs that should inform architecture and design.

Brenna also points out that while basic AI code may work initially, it becomes problematic as needs change. “It might even do what you want it to do. As long as you test it. But inevitably, if you need to change the code, you’re in a bit of a bind because it’s not human readable.” Without readable structure and meaningful naming, modifying AI code becomes arduous.

By understanding these tradeoffs, engineering teams can strategically use AI generation where appropriate while avoiding pitfalls. With human guidance, machine coding can boost productivity without technical debt accumulation that cripples agility over time.

Example of Github Copilot in action
Example of Github Copilot in action

Integrating AI-Generated Code into Codebases

Once we recognize both the benefits and risks of AI-written code, the next step is learning how to integrate it responsibly. According to Brenna, seamlessly integrating auto-generated code into codebases requires thoughtful human guidance. She emphasizes encapsulating AI code into modular components for refinement and employing semantic naming conventions for readability. These best practices align with techniques used by top AI coding tools like GitHub Copilot.

Following these recommendations and the practices modeled by the experienced team at Emerge, development teams can smoothly incorporate machine-generated code through:

  • Encapsulate: Isolate any AI-generated functions or classes into separate modules. For example, if Copilot produces code for a utility calculating tax, encapsulate it in a distinct TaxCalculator module. This makes it easy to refine or replace that component without impacting overall architecture.
  • Rename for Readability: Give variables and functions clear semantic names that reflect purpose and business logic. Instead of Copilot’s generic id parameter, name it customer_id to capture meaning. Similarly, rename calc_total() to calculate_order_total().

  • Test Thoroughly: Build comprehensive unit test suites that validate intended behavior and edge cases. For the TaxCalculator module, create tests validating calculations for different tax codes, high/low amounts, error conditions, etc. This surfaces issues early before integration.

  • Document Usage: Use Python docstrings or JSDocs to explain a module’s purpose, parameters, returns, exceptions, and examples. Documenting AI code aids future maintenance and modifications when the original purpose is unclear.

  • Refine, Don’t Just Copy: Review auto-generated code critically instead of accepting it outright. Refactor, add validation checks, ensure alignment with security and architecture standards. The human touch remains vital.

With strategic encapsulation, rigorous testing, documentation and responsible refinement, AI coding can integrate into sustainable architectures without technical debt accumulation.

When AI Coding Tools Help vs Hurt

With best practices for integration in mind, when should teams utilize AI coding versus rely on traditional development? Understanding appropriate use cases is crucial for maximizing gains without inadvertent harm. According to Brenna, misapplying machine-generated code risks undermining agility.

AI tools excel at rapid prototyping of standalone functions. Their ability to quickly generate functional code allows exploring many permutations early in development. This provides flexibility without delay.

Conversely, depending heavily on AI generation for core product architectures can hurt long-term velocity. Unlike human engineers, AI lacks insight into shifting business priorities that should inform design. Change becomes slower and institutional knowledge gets lost if code is unfathomable.

Another area where AI assists is filling gaps for overburdened teams. AI meeting assistants can help track the information from meetings and help team members be more productive, freeing up employees to focus on higher-value work. Similarly, AI coding tools that automate writing of rudimentary CRUD APIs and scripts enable developers to direct their efforts toward the more complex, creative challenges better suited for human engineers. This avoids burnout while leveraging machine productivity where appropriate.

However, handing off core product capabilities to AI risks erosion of quality over time as debt accumulates. Some bugs and limitations only emerge in complex integrated systems, requiring human discernment to address holistically. Automated coding alone cannot satisfy users like deliberative engineering can.

By understanding these tradeoffs, digital product teams can develop guidance on when AI generation shines versus relying on traditional coding. With smart implementation policies, AI can be applied selectively to supercharge productivity without relinquishing hard-won agility.

Best Practices for Leveraging AI Coding Tools

To maximize gains while minimizing harm, establishing governance around AI code generation is crucial. AI coding tools hold great promise for accelerating development, but also risks if used recklessly. By establishing governance and engineering rigor, organizations can responsibly leverage automatic code generation. Consider the following best practices:

  1. Set clear policies on appropriate AI tool usage in documentation and training to align teams. Define where human coding is required.

  2. Use AI for early stage prototyping to quickly explore solutions, but have engineers own critical production code.

  3. Require code reviews and approval of all auto-generated code before acceptance to enforce quality standards.

  4. Refactor AI code for readability and integration before release, with human oversight on naming and architecture.

  5. Subject all AI-written code to extensive unit, integration and regression testing to surface defects early.

  6. Monitor AI code in production for emerging issues and technical debt, refunding periodically.

  7. Build suites of integration tests covering edge cases to validate ongoing resilience as code evolves.

  8. Provide engineers time allocated specifically to technical debt reduction and refactoring of AI-generated code.

With the right combination of governance, rigor and pragmatism, organizations can harness AI productivity gains sustainably. Set your teams up for success.

The Future of AI Coding Tools

As coding teams implement responsible AI strategies today, rapid advancements point to an even more collaborative future. While AI coding tools already boost productivity today, the technology is still maturing. As machine learning continues advancing, what might the future hold?

According to Brenna, a major milestone will be AI gaining more nuanced understanding of business needs and semantics. She explains: “It would be lovely if AI could gain a deeper semantic understanding of what you are trying to accomplish from a business perspective.”

With increased contextual comprehension, AI could automatically generate more readable code using appropriate domain-specific terminology. This would allow it to generate more readable code using the appropriate business terminology.

Rather than just producing isolated functional code, future AI could architect entire systems tailored to shifting business goals. Brenna envisions engineers having high-level dialogs with AI assistants to describe desired solutions in plain language. The AI would then translate requirements into optimally designed software.

While reaching this full potential remains aspirational today, progress is rapid. Engineers may soon be able to capture requirements through natural interaction. AI assistants could handle much coding mechanics while engineers focus on creativity.

Of course, human oversight will remain essential moving forward given software’s complexity. But by automating lower-level coding, future AI tools promise to amplify human abilities exponentially. The most leverage comes from true collaboration.

Developers developing
Could AI Tools reduce the need for human pair programming?
Photo by Desola Lanre-Ologun on Unsplash

Forging the Future of Human-AI Collaboration

AI holds enormous potential for assisting overburdened engineering teams and expanding coding accessibility. But as with any powerful technology, responsible governance and diligent integration is key. By codifying and sharing best practices, digital product teams can fulfill the promise of AI generation while building lasting agility.

Forward. Digital. Thinking.

© 2024 EMERGE. All Rights Reserved.