There are a few tell-tale signs that can provide a general indicator that answers and accompanying example code were pasted from ChatGPT.
Once you've seen them, it's hard not to spot them when they pop up in the wild. And while not a guarantee that the answer is AI-written, they are strong indicators that are often worth further investigation.
As for code correctness, if perfect-looking example code has a glaring error typically only caught by intellisense, something's probably wrong. ChatGPT tends to prefer explicitly naming variable types over inference, so it's rare (in my experience) to see var foo = something()
(C#) or auto bar = another()
(C++).
If reviewing an answer to determine if it is human or not, it's probably worth your time to paste it into an IDE, if you don't already.
Presumptive Type Classification
Many property classes in C# provide a getter function, named the same as the class name, prefixed with Get
. Likewise for methods returning a collection, GetAll
. This is usually by design, but it is not always the case, especially when dealing with code introduced very early on before adopting this naming convention.
using System.Net.NetworkInformation;
IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); // truth
//...
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces(); // truth
foreach (var ni in interfaces) {
IPProperties ipProperties = ni.GetIPProperties(); // fiction
//...
}
Just because the GetIPGlobalProperties()
and GetAllNetworkInterfaces()
methods use their class names verbatim, does not guarantee that a GetIPProperties()
method is part of the IPProperties
class. Indeed, such a class does not exist in the System.Net.NetworkInformation
namespace. GetIPProperties()
is actually part of the IPInterfaceProperties
class.
Similarly, the existence of an enum specifically describing common interface types (NetworkInterfaceType
), does not mean every possible connection type in existence is included.
using System.Net.NetworkInformation;
if (ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet // truth
|| ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 // truth
|| ni.NetworkInterfaceType == NetworkInterfaceType.Bridge) // fiction
{
//...
}
Both of the above errors are easily apparent when pasted into an IDE, but ultimately would go unnoticed except to the most astute programmer with significant first-hand experience using these specific .NET classes, as the following unaltered snippet from a ChatGPT response shows:
Symmetric Sentences
Example code is often introduced and summarized by a single sentence, using a consistently recognizable sentence structure with very little - if any - deviation from the following:
Standalone introduction sentences (meaning a single-sentence paragraph) begin with:
- "To get/display ..."
- "For example, ..."
Multi-sentence introductory paragraphs typically use the modified form "To do this, ..." in the last sentence of the paragraph.
Summary sentences will begin with one of the following, with very few exceptions:
- "This will display/return ..."
- "In this example, ..."
These tend to be paired, meaning an example introduced with "For example..." will invariably be followed by a summary beginning with "In this example...". Introductions beginning with "To display..." are followed by summaries beginning with "This will display...".
GPT-3
đ