ISTM another plausible meaning of "magic string" is just like a magic number but a string instead. This would be a string used to store information that would
| This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
ISTM another plausible meaning of "magic string" is just like a magic number but a string instead. This would be a string used to store information that would be better stored using symbolic constants or possibly a boolean variable.
And the string could be purely internal, or it could be in a UI component. The latter is a bit like the kind of magic string that the article talks about, except that rather than being in a text input control, it might be in the text label of a button or the like (this is a form in which I have recently encountered it). That said, maybe this is just one case of a more general kind of anti-pattern for which there ought to be a name: storing state information in GUI controls for later retrieval.
Comments? -- Smjg (talk) 19:38, 16 December 2008 (UTC)
This article seems to be the result of someone just making up what they believe magic strings to be. Magic strings are analogous to magic numbers and generally refer to the use of strings as a token for some state or entity. I would submit they are referred to as “magic” more as a carry over from its derivation from the concept of magic numbers. The term “magic” here refers to the vagueness in meaning of the token used, or the lack of clarity that exists in how a process enters into the state. —Preceding unsigned comment added by 66.196.25.254 (talk) 15:54, 31 July 2009 (UTC)
Rswelker: On Daydreamer302000's suggestion, collecting references to one use of the term "magic string", i.e. in reference to a hard-code literal (a token).
As a professional programmer of ~20 years I've always understood it to be like a magic number. Rswelker (talk) 01:09, 23 September 2009 (UTC)
Daydreamer302000's view may have once been correct and exclusive but it seems common usage is now different - at least in some circles.
int act(string scene)
{
if (scene == "Fireswamp")
{
Attack("ROUS'S");
}
else if (scene == "Reunion") // In the movie, not the book.
{
Cry("As you wiiiiissshhh...");
}
}
Who wrote this stuff? Does it make any sense? Not from what I can read in the comments. The intro specifically makes no sense whatsoever! Rui ''Gabriel'' Correia (talk) 22:17, 29 January 2014 (UTC)
"The term comes from the fact that this type of problem is often seen in Windows Forms with editable text boxes for input."
I'm removing this as it makes no sense. Aside from the claim that this constitutes a "fact", how can one reach the phrase "magic string" from Windows Forms, as opposed to any other GUI API? Indeed, how does one need to go through a GUI (as opposed to a text-based UI or even an input file format) in order to coin this phrase? I've just had a look at the cited reference (in Internet Archive), and it says nothing of the sort.
On browsing the page history, I have found that it previously said "web forms", citing the same reference. But the reference doesn't, as far as I can see, say anything about the etymology of the phrase. Indeed, it seems to me that, literally speaking, it's just a string on which some magical power has been bestowed by the system within which it is used. This is neutral with respect to the mechanism by which it has been input into the system. — Smjg (talk) 13:23, 13 March 2017 (UTC)
Others have pointed out that "magic string" could be a special case of "magic number". I can accept that this article is referring to a different meaning, but if that is the case, footnote 1 is not supporting the opening paragraph at all, but rather referring to the "magic number" definition rather than the "cheat code" definition. I just flagged the post with the "better citation needed" template. Let me know, or correct it if there is a more appropriate template.ShatteredNode (talk) 21:58, 6 January 2026 (UTC)
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.