Contact us
facebookLinked InYoutube
Use Case
HomeUse CaseBlogCoding Cisco products and others via AI Coding Assistant

Artificial Intelligence (AI) is transforming the way we work, and software development is no exception. As software
development becomes more and more complex and time sensitive, the role of AI in this field has grown
significantly.

 

What is AI Coding Assistants?

AI coding assistant is a software tool or application that leverages AI techniques to assist developers in writing,
editing, reviewing, debugging and optimizing code. It is designed to enhance the productivity and efficiency of
developers by providing various automated features and intelligent suggestions throughout the coding process.
It generates codes based on prompts in natural language or an existing code base and suggest code completions
in real-time as you type.

 

Key characteristics and functionalities

Code suggestions and completion – Similar to auto-complete in modern IDEs (Integrated Development
Environment), AI coding assistants offer intelligent code completion suggestions as developers’ type, predicting the
next lines of code based on the context, previously written code, and commonly used patterns. This feature helps
save time, reduce typos, and improve accuracy.

Code generation and scaffolding – AI coding assistants can automatically generate code snippets or templates
based on high-level descriptions or requirements provided by the developer. This feature helps in quickly
scaffolding basic code structures or generating repetitive code segments.

Code reviews – These tools can spot potential issues, bugs or deviations from best practices during code reviews.
They can identify opportunities for code optimization, suggest alternative coding approaches, and assist in applying
best practices and design patterns.

Code optimization – AI coding assistants help to analyze the code, identify areas that can be improved or
optimized and also provide suggestions for optimizing code snippets for better performance or memory usage,
which is essential for maintaining software quality.

Bug/error detection and debugging – AI coding assistants can analyze code in real-time and detect potential
errors, bugs, or vulnerabilities. They highlight problematic lines of code, offer suggestions for fixes, and provide
explanations for error messages, helping developers identify and rectify issues quickly.

Refactoring suggestions – AI coding assistants can provide recommendations for refactoring existing code to
improve its quality, readability, and performance. Apart from that, they can offer help with refactoring tasks to
improve code maintainability and structure.

Code search and documentation – AI coding assistants can search through extensive code repositories,
documentation, and online resources to retrieve relevant code examples, usage patterns, and documentation
snippets. This helps developers find answers to their coding questions and learn from existing code.

Contextual help and code explanations – AI coding assistants can provide contextual help and explanations for
code snippets, APIs, and language constructs. They assist developers in understanding complex concepts,
providing documentation references, and offering usage examples. By offering context-aware documentations,
they empower developers to make informed decisions while coding.

 

Benefits

Improved efficiency and productivity – By automating repetitive tasks and suggesting code completions,
the developers can code faster and smarter, reducing manual typing and repetitive tasks. This allows the
developers to focus on more critical and creative aspects of the software development.

Reduced errors and bugs – AI coding assistants identify potential errors and bugs before they occur, improving
code quality and minimizing debugging time. This translates to fewer bugs, reduced downtime and a more reliable
software product.

Increased accuracy and consistency – AI coding assistants help to ensure that the code is consistently formatted
and executed by enforcing best practices and coding styles as well as creating more consistent and standardized
code across project. This improves code readability for all developers working on the project.

 

Examples of AI coding assistants

The above are some of the popular AI coding assistants in the market. These assistants use machine learning,
natural language processing (NLP), and other AI techniques to provide intelligent coding support tailored to
specific programming languages and development contexts.

For the demonstration, I will be using Codeium to illustrate the capabilities and features of AI coding assistants.

 

Use case demos

1. Configure Cisco APIC

For the first demo, I am going to write some Python codes to make REST API calls to Cisco APIC to list all the
existing tenants and then configure a new tenant, with the help of Codeium Chat.

To begin, I need to write some Python codes to login to Cisco APIC and then retrieve all the tenants configured. To
ackle this, I can ask this in Codeium Chat, and it will generate the sample codes that I can use by replacing the
relevant parameters specific to my working environment.

 

Once the code modification is done, I can execute it in the terminal console, and it will return the list of tenants
from Cisco APIC.

 

Now the code is ready to obtain the list of tenants from Cisco APIC. Next, I would like to know how to add a new
tenant, so I ask that in Codeium Chat again. It will generate another sample code that I can use in my Python file.

 

I just need to modify the codes to specify the new tenant’s name that I would like to have, then I can execute my
Python file to go ahead to create the new tenant. In the terminal console, I can see that the new tenant’s name
called “nttcomdd-tenant” is created successfully.

 

To verify everything is working fine, I login to Cisco APIC and indeed I can see the new tenant has been created
successfully.

This concludes the first demo of how easily we can write codes to communicate with Cisco APIC via REST API by
asking Codeium chat to generate sample codes for us to kickstart.

 

2. Migrate Cisco NX-OS VLANs to ACI Bridge Domain

For the second demo, the task is to write some codes to migrate all the VLANs in Cisco NX-OS device to Cisco ACI
as “bridge domains”.

Again, I will ask Codeium Chat to generate the sample codes that I can use to perform the VLAN migration to
bridge domains.

 

I just need to paste the sample codes to the right section of my Python file and then modify the relevant
parameters like the APIC IP address and bridge domains naming convention. Once it’s done, I can execute the
Python file to start the migration.

 

To verify that the migration is successful, I login to Cisco APIC and check all the bridge domains under the tenant.
From the screenshot above, all the NX-OS VLANs have been migrated to ACI bridge domains.

 

3. Create a website

For the third demo scenario, I would like to develop a simple website by writing some HTML codes.

To begin, I post my request in Codeium Chat so that it will generate a sample HTML code to speed up my website
development. I just need to copy and paste the sample code to my new index.html file. From there, I can modify
some of the display text according to my needs. When it is ready, I am going to launch a web browser to check
out my new website page.

 

This is how the new website looks like for now. The next task is to add a new about page. I can do the same with
the help of Codeium Chat again.

 

Here I ask another question to help generating the about.html page. Again, the AI coding assistant tool will return
another set of sample codes for me to use. I just need to create a new file called about.html and then paste the
codes there.

 

This is how the about.html page looks like with similar look and feel with the main page.

 

4. Write a number guessing game

In this fourth demo scenario, I would like to develop a “number guessing” game by writing some Python codes.

In Codeium Chat, I post my request asking for help. Within seconds, the tool will generate example codes to
complete the number guessing game development. I can test out the game by executing the Python file. In the
terminal console, the game will ask me to enter a number between 1 and 100 as my number guess. After 3
attempts, I managed to guess the correct number.

 

5. Generate regular expression for date pattern

Now come to the fifth demo scenario, I would demonstrate how AI coding assistant like Codeium can quickly help
me to solve some complex codes development.

As you can see from the screenshot above, the moment I have created a variable called date_pattern, the AI
coding tool is intelligent enough to generate the relevant regular expression for the date format. This really saves
my time to manually code the date regular expression.

 

I have also written some test cases to verify if the regular expression generated by the coding assistant is correct.
For the three test cases, they do return valid results. Thus, I can confirm that the regular expression for the date
pattern is correctly defined.

 

6. Perform unit testing

In this last demo scenario, I would write some codes to perform unit testing for one of the functions that I have
developed.

The function to be tested is called intersection() which is to return the elements exist in both lists. By entering the
comment to indicate that I want to write some function test codes using assert, the AI coding assistant tool will
automatically suggest the code required. I just need to press Tab key to complete it. How intelligent this is!

 

When the codes are ready, I just have to execute the Python file to verify that the new intersection() function is
developed correctly. No exception is thrown during the code execution, which is the expected behavior.

     

    Summary

    In a nutshell, AI coding assistants aim to augment developers’ capabilities, increase productivity, and facilitate the
    development process by providing automated suggestions, error detections, code generations, and relevant
    information at various stages of the coding process. After going thru all the demo scenarios, I hope that now you
    would have a clearer picture of how AI coding assistants work and how we can make use of them to simplify our
    code development. I look forward to seeing you to explore this area further and gain benefits from there in the
    near future.

     

    Return to List