Getting Started with Coding
Book cover titled 'Getting Started with Coding' second edition with cartoon kids and binary code.
Explore Book
Buy NowSubscribe on Perlego
Getting Started with Coding
Book cover titled 'Getting Started with Coding' second edition with cartoon kids and binary code.Explore Book
Buy NowSubscribe on Perlego

Generative AI coding tools can improve your productivity as a coder, remind you about syntax, and even help you with testing, debugging, refactoring, and documentation, but it's up to you to know how to use them correctly. Get ten prompt engineering tips that can make the difference between AI spitting out garbage spaghetti code and crafting elegant code that works.

AI coding tools present unique challenges and hazards for software development teams, so check out some simple rules to make sure that generative AI doesn't tank your project. Then see what happens when ChatGPT is asked to list the top things human coders do that AI can never replace.

Prompting tips for coding with AI

The process of figuring out the right prompt to give a generative AI tool to ensure a high-quality result is called prompt engineering. However, designing prompts is more of a creative art than a formal engineering discipline. Using trial and error, people have discovered techniques and phrases that reliably increase the quality of generated code. Here are my top ten tips for effective prompting of generative AI chatbots.

  • Use active voice. Instead of writing "It is desired to" write "The code should" or "I want."
  • Avoid using negations. Instead of writing "Don't use loops," write "Use recursion instead of loops."
  • Specify a role. Start your prompt by describing the role the AI should emulate. For example, you might write "You are an experienced and highly skilled programmer."
  • Emphasize code quality. Use phrases such as clean code, readable, and well-documented in your prompts.
  • Mention specific libraries, frameworks, and APIs. If you expect the generated code to use certain tools, mention those (along with versions if appropriate) in your prompt.
  • Start with an explanation of the overall problem. Doing so gives the AI tools a foundational understanding of the outcome you want.
  • Describe the input and output data formats. Even when it may be obvious to you that a function named sumNumbers() should accept numbers as its arguments and return a number, providing that information in your prompt will limit the number of choices the AI has to make and will improve the quality of its response.
  • Break down complexity. Focus on solving one small chunk of a problem at a time.
  • Be clear and concise. Avoid ambiguity and vague words such as good or efficient.
  • Work iteratively. Don't settle for the first generated result. Iterate and refine your prompt and provide feedback to the AI tool to guide it towards a desired result. Sometimes, changing one word in your prompt can dramatically affect the output.

Basic coding vocabulary

Coding has an extensive vocabulary that to a layperson might seem like impenetrable techno-babble. Whether you’re reading a coding-related article online or speaking to a developer at work, you may hear words that are unfamiliar or have a different meaning in a coding context. This section defines some common vocabulary words to know.

General coding terms

Algorithm: A step-by-step procedure or set of rules for solving a problem or performing a computation, often implemented in code.

API (Application Programming Interface): A set of rules and protocols for building and interacting with software applications, allowing different programs or systems to communicate and exchange data.

Back-end: The behind-the-scenes functionality that powers the front-end. Back-end developers use languages such as Ruby, Python, or Java to implement features like user authentication, storing preferences, and retrieving data.

Bug: An error, a flaw, or an unintended behavior in code that causes a program or website to malfunction or produce incorrect results.

Build: The process of converting source code into a finished product, such as a compiled application or deployed website. The process might involve steps like transpiling, bundling, and minifying code.

Client: A device used to access a website, such as a desktop or laptop computer, tablet, or mobile phone.

Commit: A recorded change to a repository in version control systems. Commits include a message describing the modification and help document project history.

Dependency: An external library or package required by a project. Projects often rely on dependencies to add features without writing everything from scratch.

Designer: An artistic professional responsible for determining a website’s visual style and user experience, including how users interact with elements like clicking, swiping, or scrolling.

Developer: An engineering professional who writes code to transform wireframes into functional websites. Developers may specialize in front end, back end, or full stack.

Diff: A comparison between two sets of code or files, highlighting what has changed. Often used in version control systems to show additions, deletions, or modifications.

Framework: A collection of prewritten code, libraries, and tools (such as React, Angular, or Vue.js) that helps developers build complex applications more efficiently.

Front-end: All visible and interactive elements in a web browser. Front-end developers use languages such as HTML, CSS, and JavaScript to create the website’s appearance and user interface.

Library: A collection of reusable code that provides specific functionality, like handling dates or making network requests, which developers can include in their projects.

Linter: A tool that automatically checks source code for potential errors, stylistic issues, or deviations from coding standards, helping developers write clean, readable, and well-documented code.

Pull request: A request to merge code changes from one branch or repository to another, typically reviewed by other developers before acceptance.

Repository (repo): A storage location for source code and related files, often managed with version control systems like Git. Repositories help teams collaborate and track changes over time.

Server: A computer that hosts website code and serves website content when requested by a client device. Servers typically reside in large data centers alongside thousands of other servers.

Source code: The original set of written instructions for a program or website, typically created by developers and readable by humans.

Wireframe: A detailed illustration created by designers showing a website’s layout, images, and color schemes, serving as a blueprint before development.

Terms related to front-end development

Accessibility (a11y): Designing and developing websites so that people with disabilities can use them effectively

API (Application Programming Interface): A set of rules and tools for building software and applications, often used to fetch data from servers to display on web pages

Bootstrap: A popular CSS framework that provides ready-made design templates and components for building responsive websites quickly

CSS (Cascading Style Sheets): A style sheet language used to control the appearance and layout of web pages, including colors, fonts, spacing, and positioning

Component: A reusable piece of user interface (UI), such as a button or navigation bar, often used in modern front-end frameworks

DOM (Document Object Model): A programming interface that represents the structure of a web page, allowing JavaScript to access and manipulate HTML and CSS

Framework: A collection of prewritten code and tools (such as React, Angular, or Vue.js) that help developers build complex and efficient front-end applications

HTML (HyperText Markup Language): The standard language used to create and structure content on the web, such as headings, paragraphs, links, and images

JavaScript: A programming language that enables interactive features on websites, such as form validation, animations, and dynamic content updates

Responsive design: An approach to web design that ensures that websites look and function well on devices of all sizes, from smartphones to desktop monitors

Terms related to Python

Class: A blueprint for creating objects in Python, encapsulating data and behaviors together

Decorator: A special function in Python that modifies the behavior of another function or method, often indicated with the @ symbol

Dictionary: A collection in Python that stores key-value pairs, allowing for quick lookup of values based on keys

Django: A high-level Python web framework that encourages rapid development and clean, pragmatic design

Exception: An error that occurs during program execution, which you can handle with try and except statements in Python

Flask: A lightweight Python web framework used to build simple web applications and APIs

Generator: A function that returns an iterator and yields items one at a time, using the yield statement, allowing for memory-efficient looping over data

Indentation: The use of spaces or tabs at the beginning of a line, which in Python determines code grouping and flow, such as inside loops or functions

Interpreter: The program that reads and executes Python code line by line, translating it into actions for the computer

Jupyter Notebook: An interactive web-based environment for writing and running Python code, often used for data science and exploratory analysis

List: A collection type in Python that holds ordered items, which can be changed or updated

List comprehension: A concise way to create lists in Python using a single line of code, often with a for loop and an optional condition

Matplotlib: A Python library for creating static, interactive, and animated visualizations such as graphs and charts

Module: A file containing Python code (functions, classes, variables) that can be imported and reused in other programs

NumPy: A popular Python library for numerical computing, providing support for large, multidimensional arrays and mathematical functions

Object: An instance of a class, representing a specific entity with its own data and functionality

Pandas: A widely used Python library for data manipulation and analysis, especially for working with tabular data via DataFrames

Pip: The standard package manager for Python, used to install and manage additional libraries and dependencies

PyPI (Python Package Index): The official online repository for Python packages, where users can publish and download libraries

TensorFlow: An open-source Python library developed by Google for machine-learning and deep-learning applications

Tuple: An immutable collection type that holds ordered items, meaning its contents cannot be changed after creation

Virtual environment (venv): An isolated workspace for Python projects, ensuring that dependencies for one project don’t affect others

AI glossary

API (Application Programming Interface): A set of tools and protocols for building and integrating AI-powered applications

Bias: A systematic error in AI models caused by unfair or unrepresentative training data

Dataset: A collection of data used to train and test AI models

Deep learning: An advanced form of machine learning that uses many layers of neural networks for processing complex data

Fine-tuning: Adjusting a pretrained AI model for a specific task or dataset

Inference: Using a trained AI model to make predictions or decisions based on new data

Machine learning (ML): A subset of AI focused on building systems that learn from data and improve automatically

Model training: The process of teaching an AI system using datasets, so it can make accurate predictions or classifications

Natural language processing (NLP): The branch of AI concerned with enabling computers to understand and generate human language

Neural network: A computational model inspired by the human brain, used for tasks such as image recognition and language processing

Prompt engineering: Designing effective prompts to guide AI models in generating desired outputs, particularly in generative AI

Reinforcement learning: A machine-learning technique where an agent learns by interacting with its environment and receiving rewards or penalties

Supervised learning: A type of machine learning where models are trained on labeled data

Tensor: A multidimensional array used in AI coding, especially in frameworks such as TensorFlow and PyTorch

Unsupervised learning: Machine learning on unlabeled data to discover patterns and relationships

References and resources for the beginning programmer

HTML, CSS, and JavaScript are the most common front-end coding languages. Following is a list of some online resources, references, and tutorials to help you continue practicing all three languages:

About This Article

This article is from the book: 

About the book author:

Chris Minnick is an accomplished author, teacher, and programmer. Minnick authored or co-authored over 20 books, including titles in the For Dummies series. He has developed video courses for top online training platforms and he teaches programming and machine learning to professional developers at some of the largest global companies.

Paul McFedries is a Google® Workspace administrator, a thankless job if ever there was one. Paul is also a full-time technical writer who has somehow found the time to write more than 100 books that have sold more than four million copies worldwide.

John Paul Mueller is a freelance author and technical editor. He has writing in his blood, having produced 100 books and more than 600 articles to date. The topics range from networking to home security and from database management to heads-down programming. John has provided technical services to both Data Based Advisor and Coast Compute magazines.

Luca Massaron is a data scientist specialized in organizing and interpreting big data and transforming it into smart data by means of the simplest and most effective data mining and machine learning techniques. Because of his job as a quantitative marketing consultant and marketing researcher, he has been involved in quantitative data since 2000 with different clients and in various industries, and is one of the top 10 Kaggle data scientists.

John Shovic, PhD, is a computer science faculty member at the University of Idaho specializing in robotics and artificial intelligence.

Alan Simpson is a web development professional and prolific tech author with more than 100 publications to his credit.