|WikiProject Computer science||(Rated Start-class, Low-importance)|
Difference between snippet and some other concepts
How does a snippet differ from other reusable programming constructs, such as functions, macros, objects, and the like? Perhaps the article could go into some detail on this subject? I don't know enough to do the edits myself. Flewellyn (talk) 21:43, 18 February 2009 (UTC)
- IMHO, a snippet is just a piece of code, normally (but not necessarily) contiguous. It is not necessary a modular unit; for instance, four arbitrary sequencial lines of a routine would qualify as a snippet.
- It does not even need to be valid (compilable/executable) code as is. For instance, suppose an algorithm implemented in a given programming language. In a snippet extracted to discuss the implementation of that algorithm, the contents of one of its inner loops may be omitted and replaced by "..." to explain the basics of a portion of that algorithm while ignoring irrelevant details to that explanation. So a snippet does not need to be created with reuse in mind; there can be snippets for didactical reasons too.
- Thus, snippet would be an umbrella term for all those modular units you have mentioned and even pieces of code that are just part of a module (or parts of different modules). However, the term is typically used to refer to a small piece of code. It would be somewhat misleading to call a module of many KLOC a snippet. --Antonielly (talk) 22:10, 18 February 2009 (UTC)
I’ve given an answer to this question in this edit, with contrasting examples. My understanding is that snippets are literally (statically) included text, as opposed to the abstraction of macros and functions; this accords with how it’s used in the cited source code editors. You thus can’t change snippets after they’ve been inserted, but OTOH they avoid overhead because they simply include code, without requiring indirection (“what does this macro expand to?”). Hope this helps!
"The following is a summary of snippet support in some applications such as text editors and IDEs. For more details, see also Comparison of text editors."
- The link to "comparison of text editors" does not lead to a snippets section on the comparison page... there is no catergory on the comparison page for snippets... No longer relevant? Fix? or Remove? Red Summer Rain (talk) 18:03, 7 April 2009 (UTC)
- Provide an in-context definition and we can determine from that. Where did you see this term? dr.ef.tymac (talk) 11:32, 10 December 2009 (UTC)
POV issues with copy-paste programming pejorative
The copy-paste programming pejorative added into the context of this article seems to be conflating the basic feature of "snippet management" with a programming methodology, purportedly used by inexperienced programmers.
The copy-paste programming phenomenon (to whatever extent it exists) is not the same thing as "snippet management" which is simply a basic feature of professional programming tools such as IDEs and Programmer-oriented text editors. These tools allow editors to simply reduce the risk of repetitive strain injury and other related issues, by obviating the need to manually type keystrokes for routine tasks.
See e.g., Saving Keystrokes with Macro-Like Snippets http://komodoide.com/blog/2012-12/saving-keystrokes-macro-snippets/