CSC1002 Week3 AI Prompt
CSC1002 Week3 AI Prompt
Programming
Design - Tradeoff
Problem Decomposition - Function
Clean Code - Single Responsibilty
• Clearly de ned behaviour, with one clear task to perform
• Short in number of lines of code, say < 15 lines
• Clear Input and Output
• Prefer a function with fewer parameters, no more than three
fi
Goal #1 - AI Assisted Coding
Future Programming - AI as Programming Copilot
• When rst learning to program, learners often dedicated a signi cant amount of time working
with the syntax and fundamental structure of programs.
• As AI technology advances, the focus for learners will shift towards design, coding strucrture
and testing (Clean Code)
• Through guided interaction called prompt, we will demonstrate how the AI Assistant
facilitates the completion of coding in each function based on the descirbed behavior from
the prompt,
• By the end of the lecture, students will have gained a good understanding of how AI
technology is reshaping the future of programming development, including how to integrate
AI technology as a programming helper and how to leverage the AI Assistant to bootstrap
software development.
• Code Generation - Generate logic for the entire function/Program based on user-provided
speci cation and user-speci ed constraints using latest generative AI technology.
• Code Translation - Translate logic from one language to another, or one format to another (ex: JSON
to Class)
• Defeat Detection - Complexity tends to increase due to CHANGES, it aims to detect unknown errors
and error-prone logic.
correct
Done
fi
AI Assisted Prompt
Prompt - Input to Generative AI
Text in natural language
• In the context of Generative AI, the manner by which we engage AI system is conversation
called PROMPT, simply a piece of text in natural language.
• The QUALITY of prompt directly dictates the accuracy of the responses from the AI system.
• In summary, a well-de ned prompt is the recipe for a successful conversation that facilitates
understanding of the topics of interest. For examples:
Context
Example 3
Instructions
Question
Prompt - Role
Prompt - Examples
Great product, 10/10: positive
Didn't work very well: negative
Super helpful, worth it: positive
It doesnt work!:
Add 3+3: 6
Add 5+5: 10
Add 2+2:
Guide AI to use
Sample() method to
generate the random
string
Prompt Format - Function
Input and Return
Types
Meaningful name
Parameter
Description
Return
Description
Specifc
Requirements
Examples
Implementation - AI-Assisted
Cody AI - Demo
Preparation
Open-Box
Testing
Closed-Box
Testing
Closed-Box
Testing
Another Open-Box Testing
• Ex: a function foo() that expects 2 integers as input: foo(+ve, +ve), foo(-ve, +ve),
foo(-ve, ve), foo(-ve, -ve), foo(0,0), foo(0,+ve), foo(+ve, 0)
• Exception Cases
• These are inputs that might test some of the rules for the function in more depth or
contain unexpected inputs
• Out of Range Input, Empty, Invalid Input, Large Value, List with Large Items, …etc
fi
The End - Thank you