AI isn't the solution to all problems

Christopher Harrison - Jul 26 '23 - - Dev Community

There's an old saying "If the only tool you have is a hammer, everything looks like a nail." The basic message is if you're using a single solution you're likely to force its usage to solve every problem, even if it isn't the best tool for the job. This is a trap we often fall into when we're handed a new shiny tool, like AI. We immediately want to apply it to every scenario, even when there are existing options which are better equipped. I'm seeing this quite a bit these days with AI, with new products capturing the imagination of developers everywhere. But before we reach for AI we need to stop to ask if this is the right tool or is a better tool already available.

As an example, I recently attended a hackathon where a team was building an app to help developers create accessible websites. They were asking questions about how to incorporate AI into the process, using AI to detect accessibility shortcomings. As it turns out, this is a solved problem.

Looking at web development specifically, there's a set of clearly defined standards. There are numerous tools, including Visual Studio Code extensions and GitHub actions which can detect and report on gaps in compliance. Because detection is pattern based, there isn't a need for the dynamic capabilities AI would bring to the table. While it's certainly possible to build a new AI-driven tool, it wouldn't improve the process. This falls into the "hammer/nail" category.

However, there is a space where AI an help developers improve the accessibility of the apps they build. When we look at existing tools, the feedback provided to developers is relatively generic. An error might be raised indicating an alt attribute is missing from an img tag, but it would likely lack explanatory context. It's always better for someone to truly understand the rationale behind a rule rather than following the rule "because someone said so." Why is the alt attribute important? What makes for good alt text? What are the best practices?

Using a tool like GitHub Copilot Chat, a developer could highlight a block of code and ask questions like the ones listed above. It's a great opportunity to interactively learn more about accessibility, the experience different users have on a website, and how best to ensure the pages they build are usable by everyone. The information will be contextual to their specific situation, making it more relevant and impactful to the developer.

GitHub Copilot can also aid developers in creating accessible code. GitHub Copilot offers suggestions based both on its model and the current development context. If the HTML the developer is editing follows good accessibility practices, GitHub Copilot is more likely to make suggestions which do the same. A developer can also prompt GitHub Copilot by saying things like "Create a link to /login using the login.png image ensuring accessibility", which helps guide the suggestions generated.

In the end, we use different tools with different technologies to help our developers create accessible web pages. Extensions in the IDE alert to potential gaps. Automation integrated into the CI process catch issues before they're merged into the codebase. And finally AI helps the developer write better code, gain context and learn about accessibility.

All of us have a propensity to fall into the trap of wanting to use the cool new technology anywhere and everywhere, even if it's not an appropriate application. We always need to stop for a minute to ensure we're using the right tool, that we're not simply hammering everything as not everything is a nail. AI doesn't replace existing tools and solutions; it's another tool we can use to enhance and improve what we already have.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .