Editing 1513: Code Quality

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 8: Line 8:
  
 
==Explanation==
 
==Explanation==
This comic is the first in the [[:Category:Code Quality|Code Quality]] series:
+
<!-- °\_/° -->
* [[1513: Code Quality]]
+
{{incomplete| Needs fine-tuning and explaining of Ponytail's three comments}}
* [[1695: Code Quality 2]]
+
Ponytail is about to look at some source code Cueball has written, and he is warning her that he is self-taught so his code probably won't be written the way she is used to.  Although few programming languages require a perfectly rigid style so long as the code is syntactically accurate, most programmers follow some sort of {{w|Programming_style|style}} to make the code easier to read.  This includes indenting lines to show levels and using descriptive variable identifiers with {{w|CamelCase|"camel case"}} or {{w|Snake case}} capitalization (capitalizing each word except for the first, and separating lowercase words with underscores, respectively). In spite of Ponytail's initial (polite) optimism, she comments in three increasingly harsh and absurd similes. Firstly, she suggests that reading his code is like being in a house built by an unskilled child, using a small axe to put together what he thought was a house based on a picture. Secondly, she suggests that it looks like a salad recipe, written by a corporate lawyer (who are notoriously difficult to understand), on a phone with autocorrect that only corrected things to formulas from Microsoft Excel (which are notoriously complicated). Thirdly, she suggests that it is a transcript of the dialogue of couple arguing at {{w|IKEA}} (a world-wide chain of furniture stores which feature large, maze-like showrooms as well as a large warehouse area where you can pick up the furniture you want to buy in flat, some-assembly-required packaging; especially on weekends when many people crowd in to a store, they can be stress-inducing places), the transcript of which was then randomly edited until the computer compiled it with no errors.  Finally, Cueball surrenders and makes the rather weak assurance that he will read “a style guide”.
* [[1833: Code Quality 3]]
 
* [[1926: Bad Code]]
 
* [[2138|2138: Wanna See the Code?]]
 
  
 +
A common technique for self-taught programmers is to follow and adapt tutorials, and to find examples of similar problems being solved and try to copy the code.  This can (but doesn't always) lead to code that is hard to follow or otherwise "messy" as various different pieces of code are {{w|Jury_rig|jury-rigged}} together and tinkered with until they seem to work.  Once a piece of code is working, it is usually considered too hard to go back and rewrite it to be cleaner or clearer, also at the risk of breaking something that has been working.  This practice is known as {{w|refactoring}} and code projects that incorporate cycles of refactoring tend to be easier to read and maintain than those that don't.
  
[[Ponytail]] is about to look at some {{w|source code}} [[Cueball]] has written, and he is warning her that he is self-taught so his code probably won't be written the way she is used to. In spite of Ponytail's initial (polite) optimism, she comments in three increasingly harsh similes (and a fourth in the title text).
+
The title text refers to {{w|emoji}}, or "smiley faces". They exist in Unicode, or can be simulated using ASCII characters. Many languages will allow variable names to include underscores, so a variety of sad face ASCII emoji will be legal variable names, such as <code>T_T</code>, <code>p_q</code>, <code>ioi</code> etc. Progressively more possible crying-face emoji are possible if variables can include [http://hexascii.com/sad-emoticons/ UTF-8 characters] or full Unicode.
  
First, she suggests that reading his code is like being in a house built by a child, using a hatchet (a small axe) to put together what he thought was a house based on a picture. She is saying that the code shows a lack of command of the language being programmed. This is like the common expression "If all you have is a hammer, everything looks like a nail."  New programmers make use of the same techniques repeatedly, using them for situations where other techniques would be far more efficient or faster.
+
In the realm of Unicode, there are many crying emojis, as the comic states (e.g. 😢,😭,😂,😿,😹) In most programming languages it would be impossible to use them in variable names, as the symbols would break the language's syntax rules. A notable exception to this is {{w|Swift (programming language)|Swift}}, Apple's new programming language, in which the code can understand and use emojis in variables.  Java, as another example, allows unicode characters in variable names as long as they are letter, numeric, combining or non-formatting marks. (See [http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8] and [http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isUnicodeIdentifierPart%28int%29]).  Also, some C++ compilers support foreign Unicode characters and can have emoji in that manner.
 
 
Second, she suggests that it looks like a salad recipe, written by a corporate lawyer on a phone with auto-correct that only corrects things to formulas from Microsoft Excel. She is saying that the code is verbose and the corrections that were done are illogical. This presumably relates to the developer not being an expert in their craft, and fixing the problems as they come up instead of re-examining the problem and solving it in a better way.
 
 
 
Third, she describes it as a transcript of a couple arguing at a branch of the Swedish retail chain {{w|IKEA}}, that was then randomly edited until the computer compiled it with no errors. She is saying that the intent of the code is unclear due to the seemingly random use of the language. This is very similar to {{w|Infinite_monkey_theorem|an infinite amount of monkeys}} bashing away on typewriters for an infinite amount of time that will eventually produce the complete works of Shakespeare. (A couple's argument may be even less coherent at IKEA than at the average store, since IKEA products always have idiosyncratic names and many of them are difficult to pronounce or transcribe for anyone who doesn't speak Swedish.) This might happen if the code was written so badly that it does not compile, and people edited the code until it compiles so they can see what the code accomplishes. The fact that Cueball's code is in this bad of a shape indicates he really hasn't learned the programming language; he just happens to have a program that works in some shape or fashion.
 
 
 
Finally, Cueball makes the rather weak assurance that he will read "a style guide", which articulates the intended use of the language. It seems clear from Ponytail's commentary that his {{w|Software quality|code quality}} would benefit from far more training in computer programming.
 
 
 
The title text refers to {{w|emoji}}. Ponytail's comment implies that some of Cueball's variables contained emoji, perhaps in an effort to capture the emotional content of the arguments which show through the requirements document. Emoji have become a [[:Category:Emoji|recurrent theme]] on xkcd, but this may have been the first comic to use them for a pun.
 
 
 
===Emoji===
 
Many crying-face emoji are possible if variables can include full Unicode (e.g., 😢,😭,😂,😿,😹), as well as faces with sweat drops that are often mistaken for tears (😪,😥,😰,🥵). In some programming languages it would be impossible to use them in variable names, as the symbols would break the language's syntax rules. Exceptions to this include {{w|Swift (programming language)|Swift}} and {{w|Perl|Perl}} ([http://perldoc.perl.org/5.24.0/perlunicode.html]), but most languages with compilers that support Unicode characters can include this kind of emoji, even for languages that predate Unicode like {{w|C++}} and {{w|Lisp_(programming_language)|Lisp}}.
 
 
 
In any event, Cueball's code may best be represented by a bunch of people crying, as that seems to be the only proper response to it.{{citation needed}}
 
 
 
===Programming Style===
 
Although few programming languages require a perfectly rigid style, so long as the code is syntactically accurate, most programmers follow some sort of {{w|Programming style|style}} to make the code easier to read. This includes indenting lines to show levels and using descriptive variable identifiers with special capitalization, (e.g., {{w|camelCase}}, capitalizing each word except for the first in a sentence, or {{w|snake_case}}, separating lowercase words with underscores).
 
  
 
==Transcript==
 
==Transcript==
:[Cueball showing Ponytail his laptop.]
+
:[Cueball showing Ponytail his laptop]
 
:Cueball: Keep in mind that I'm self-taught, so my code may be a little messy.
 
:Cueball: Keep in mind that I'm self-taught, so my code may be a little messy.
 
:Ponytail: Lemme see - I'm sure it's fine.
 
:Ponytail: Lemme see - I'm sure it's fine.
  
:[Ponytail sits at desk, Cueball stand behind her.]
+
:[Ponytail sits at desk]
 
:Ponytail: ...Wow. This is like being in a house built by a child using nothing but a hatchet and a picture of a house.
 
:Ponytail: ...Wow. This is like being in a house built by a child using nothing but a hatchet and a picture of a house.
  
:[Same scene.]
 
 
:Ponytail: It's like a salad recipe written by a corporate lawyer using a phone autocorrect that only knew Excel formulas.
 
:Ponytail: It's like a salad recipe written by a corporate lawyer using a phone autocorrect that only knew Excel formulas.
  
:[Same scene.]
 
 
:Ponytail: It's like someone took a transcript of a couple arguing at IKEA and made random edits until it compiled without errors.
 
:Ponytail: It's like someone took a transcript of a couple arguing at IKEA and made random edits until it compiled without errors.
 
:Cueball: '''''Okay,''''' I'll read a style guide.
 
:Cueball: '''''Okay,''''' I'll read a style guide.
 
==Trivia==
 
*Emoji can be simulated using {{w|ASCII}} characters, but their roots are mostly separate from ASCII {{w|emoticon}}s. Most languages will allow variable names to include underscores, so some sad face ASCII emoticon will be legal variable names, such as <code>T_T</code>, <code>p_q</code>, <code>ioi</code> etc., but such things rarely show up in software variables. Many more can be made possible using UTF-8 characters, including actual emojis.
 
  
 
{{comic discussion}}
 
{{comic discussion}}
 +
<!-- Include any categories below this line. -->
  
[[Category:Code Quality]]
 
[[Category:Comics sharing name|Code Quality 01]]
 
 
[[Category:Comics featuring Cueball]]
 
[[Category:Comics featuring Cueball]]
 
[[Category:Comics featuring Ponytail]]
 
[[Category:Comics featuring Ponytail]]
[[Category:Programming]]
 
[[Category:Computers]]
 
[[Category:Language]]
 
[[Category:Emoji]]
 
[[Category:Cueball Computer Problems]]
 

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)