IS4010: AI-Enhanced Application Development

Week 02

Brandon M. Greenwell

AI tools for programming

Welcome to the AI revolution

  • Today we’ll explore the landscape of AI programming tools
  • You’ll learn to work with AI as your pair programming partner
  • We’ll compare the major players and find the right tool for each job
  • By the end, you’ll understand how to “talk” to AI about code

Course motto:

Augment, don’t automate!

  • AI is your co-pilot, not your autopilot
  • Think of AI as a brilliant but sometimes eccentric junior developer
  • AI provides suggestions → You review, approve, and own the code
  • Your job: Direct, verify, and integrate AI assistance
  • Remember: The pilot is always responsible for the flight

What are AI programming tools?

  • Code generation: Turn comments and prompts into working code
  • Code explanation: Break down complex functions into plain English
  • Debugging assistance: Help identify and fix errors
  • Refactoring support: Improve code structure and style
  • Learning accelerator: Get instant feedback and alternative approaches

Under the hood: LLMs 🧠

  • Large Language Models (LLMs): AI systems trained on massive amounts of text from the internet
  • Pattern recognition experts: They’ve learned patterns in human language and code
  • Sophisticated autocomplete: Like your phone’s predictive text, but incredibly advanced
  • Not databases: They don’t “know” facts—they predict what text should come next
  • Surprisingly good at code: Programming languages follow patterns, just like natural language

Four main categories:

  • Conversational AI models: General-purpose models (Gemini, ChatGPT, Claude)
  • Specialized code assistants: Purpose-built for coding (GitHub Copilot, Claude Code)
  • Command-line tools: Terminal-based AI access (Gemini CLI)
  • Code analysis tools: Project-wide review and feedback (Google Jules)

Conversational AI models 🤖

The big three: Gemini, ChatGPT, and Claude (These are general-purpose AI models that can help with programming.)

  • All offer free tiers - Cost shouldn’t be a barrier!
  • Strong programming support - Excellent for Python, explanations, and debugging
  • Different personalities - Each has unique strengths
  • Web-based interfaces - Easy to access
  • Great for learning - Perfect for explanations, brainstorming, and code review

Conversational coding 💬

Four ingredients of a great prompt:

  1. Context: “Here is my Python function…”
  2. Persona: “Act as a senior software developer reviewing my code.”
  3. Task: “Find any potential bugs and suggest improvements.”
  4. Format: “Provide your answer as a numbered list.”

Five essential prompt patterns

1. Explain this code

"Explain this Python dictionary comprehension step by step:

{word: len(word) for word in text.split() if len(word) > 3}"

2. Generate boilerplate

"Write a Numpy-style docstring for this function that calculates the area of a circle given its radius."

3. Refactor for clarity

"Convert this for loop into a more Pythonic equivalent using list comprehension or built-in functions."

More essential patterns

4. Debug assistance

"I'm getting a 'TypeError: unsupported operand type(s)' on line 15. Here's my code... What's the likely cause and how do I fix it?"

5. Architecture advice

"I need to store student information (name, ID, grades). Should I use a list of dictionaries or create a Student class? Explain the pros and cons of each approach."

Live demo: Head-to-head comparison 🥊

Our challenge: Create a Python function that takes a filename and returns the number of lines in the file, handling potential FileNotFoundError exceptions.

Let’s give the exact same prompt to all three AIs:

“Write a Python function called count_lines that takes a filename as a parameter and returns the number of lines in the file. Handle the case where the file doesn’t exist by returning 0. Include a NumPy-style docstring.”

What did we learn? 🧠

  • Different models, different strengths: Each AI has its own “personality”
  • Quality varies: Same prompt can yield different code quality
  • No single winner: The “best” AI depends on your specific task
  • Explanation matters: Some models explain their reasoning better
  • Style differences: Notice variations in variable naming, comments, structure

Ethics and limitations ⚠️

  • AI can hallucinate: Models sometimes generate plausible-looking but incorrect code
  • You own the code: Never submit code you don’t understand
  • Privacy matters: Be cautious about sharing sensitive info
  • Academic integrity: Document your AI usage in assignments
  • Keep learning: AI should accelerate your learning, not replace it

A quick note on docstrings 📝

  • Before our lab, we need to introduce a key concept: the docstring
  • A docstring is a string literal, enclosed in triple quotes ("""), that occurs as the first statement in a module, function, class, or method definition
  • Its purpose is to explain what the code does
  • We are learning about them now because they are the primary way you will communicate your intent to AI assistants
  • A good docstring leads to good AI-generated code

Our docstring style: NumPy

  • There are several popular styles for writing docstrings. In this course, we will use the NumPy style
  • It is clean, readable, and works very well with automated documentation tools
  • See next slide for an example

An example of Numpy-style docstrings:

def add(num1, num2):
    """
    Add two numbers together.

    Parameters
    ----------
    num1 : int
        The first number.
    num2 : int
        The second number.

    Returns
    -------
    int
        The sum of the two numbers.
    """
    return num1 + num2

Introducing Lab 02 (Part 1) 🧪

  • Your next lab assignment will give you hands-on practice with both AI tool types
  • Part 1: “Copilot driving school” - Use GitHub Copilot specifically
  • Objective: You will be given Python function stubs with NumPy-style docstrings. Let Copilot generate the implementations based on your clear documentation

AI in your editor & beyond

From browser to IDE

Why integration matters 🔗

  • Stay in your flow state: No context switching!
  • Keep your hands on the keyboard: Faster than copy-paste workflows
  • Context awareness: AI can see your entire project
  • Real-time assistance: Get help as you type
  • Professional workflow: This is how AI is used in the industry

What’s GitHub Copilot?

  • Purpose-build for coding and integrates directly into VS Code!
  • Trained specifically on code repositories from GitHub
  • Provides two main modes of assistance:
    • Inline suggestions: “Ghost text” appears as you type
    • Copilot Chat: Conversational interface within your editor
  • Context-aware: Sees your current file, open files, and project structure

The magic of inline suggestions ✨

How it works:

  • Write a descriptive comment about what you want to accomplish
  • Start coding…
  • Copilot appears as gray “ghost text”
  • Press Tab to accept, Esc to reject
  • Use Alt + ] (Windows) or Option + ] (Mac) to cycle through alternatives

The magic of inline suggestions ✨

Best practices:

  • Clear comments are key:

    # Calculate the factorial of a positive integer

  • Descriptive function names:

    calculate_factorial not calc_fact

  • Type hints help:

    def factorial(n: int) -> int:

Copilot Chat

Your conversational partner 💬

Three powerful modes:

  • Planning mode: Architectural decisions and project structure
  • Ask mode: Questions, explanations, and debugging help
  • Agent mode: Autonomous task completion and complex operations

Copilot Chat

Your conversational partner 💬

When to use each mode:

  • Planning: “How should I structure a student gradebook application?”
  • Ask: “Explain this regex pattern” or “Why am I getting this error?”
  • Agent: “Refactor this class to use data classes” or “Add error handling to all functions”

Live demo 🎬

Building a Python utility with AI assistance:

  1. Start with a comment: # A function that calculates compound interest
  2. Let Copilot generate the function: Accept or refine the suggestion
  3. Use Chat to enhance:
    • /explain the generated code
    • “Add a NumPy-style docstring and type hints”
    • /tests to generate pytest unit tests
  4. Refactor and debug: “Make this function more robust” or “Find the bug in this code”

Command-line AI assistants 💻

Why use terminal-based AI?

  • Stay in your workflow: No need to switch between terminal and browser
  • Quick queries: Fast answers without leaving the command line
  • Scriptable: Can be integrated into automated workflows
  • Code context: Easy to pipe file contents directly to AI
  • Privacy options: Some tools offer better data handling

Gemini CLI

(Free) AI in your terminal 🖥️

Common usage patterns:

# Start an interactive gemini session
gemini

# Quick code questions
gemini "How do I install [pytest](https://pytest.org/) in [Python](https://www.python.org/)?"

# Code generation
gemini "Write a [Rust](https://www.rust-lang.org/) function to read a CSV file"

# Debugging help
gemini "Explain this error: ImportError: No module named 'requests'"

Claude Code

(Not free) AI in your terminal 🖥️

What is it?

  • Anthropic’s premium CLI tool for professional development
  • Advanced features: Project context, file editing, test generation, and much, much more!
  • Industry adoption: Popular in professional development
  • Subscription required: Currently better than free alternatives

Claude Code

(Not free) AI in your terminal 🖥️

Why mention it?

  • Career awareness: You’ll likely encounter it in industry
  • Feature preview: Shows where AI coding tools are heading
  • Upgrade path: When you outgrow free tools, this is an option

Google Jules

AI-powered code review 🔍

Revolutionary approach:

  • Understands entire codebases, not just individual files
  • Comprehensive analysis: Security, performance, maintainability
  • Context-aware suggestions: Considers your project’s architecture
  • Educational feedback: Explains why changes are recommended

Google Jules

AI-powered code review 🔍

Good for:

  • Code review: Before submitting assignments or pull requests
  • Learning: Understanding best practices in real projects
  • Debugging: Finding subtle issues across multiple files
  • Refactoring: Identifying improvement opportunities
  • Addressing PRs: Example

Choosing your AI toolkit 🧰

Required for this course (free):

Recommended for this course (also free):

Your professional AI workflow 🔄

Daily development:

  1. Start with comments: Describe your intent clearly
  2. Use Copilot inline: Accept, modify, or reject suggestions
  3. Chat for complex problems: Switch to conversational help when stuck
  4. Command-line for quick help: Terminal-based queries for efficiency

Your professional AI workflow 🔄

Code review and submission:

  1. Jules analysis: Upload complete projects for comprehensive review
  2. AI-assisted debugging: Use chat to identify and fix issues
  3. Documentation: Generate docstrings and comments with AI help
  4. Testing: Auto-generate test cases with /tests command

Remember: You are the pilot ✈️

  • AI provides suggestions → You make decisions
  • AI explains possibilities → You choose the best approach
  • AI generates code → You understand and verify it
  • AI finds patterns → You apply domain knowledge
  • Always maintain responsibility for the final product

The golden rule: Never submit code you don’t understand!

Introducing Lab 02 (Part 2) 🚀

  • Part 2: “Prompt engineering challenge” - Use any conversational AI model
  • Your choice: Gemini, ChatGPT, Claude, or others
  • Objective: Debug, refactor, and document buggy Python code snippets by crafting high-quality, effective prompts using the CPTF method
  • All instructions will be in labs/lab02/README.md

Time for Lab 02! 🧪

  • Your next hands-on lab: AI-assisted Python development
  • Part 1: “Copilot driving school” - hands-on practice with inline suggestions
  • Part 2: “Prompt engineering challenge” - master conversational AI debugging
  • Please navigate to labs/lab02/README.md in the course repository for step-by-step instructions