Content Assist - Code Snippet / Code Templates

Code Snippet / Code Templates

Code snippets allow the developer to add a complex coding structure by typing a minimal amount of text. Code snippets can only be used in a valid context (statements snippets are only offered when you can insert statements).

For example, using the Eclipse IDE to code in Java, a developer can type in "instanceof" then press Ctrl+space which will replace "instanceof" by the following code snippet:

  1. if (obj instanceof MyClass) {
  2. MyClass myClazz = (MyClass) obj;
  3. }

This code snippet can be further customised by the developer, with the IDE placing the cursor:

  1. on the "obj" variable to choose between the available variables at this point,
  2. on the "MyClass" type to allow the developer to choose the type, after he pressed the tab key,
  3. on the "myClass" variable to allow the developer to rename the local variable, after he pressed the tab key,
  4. on line 3 to allow the developer to continue typing the rest of the code, after he pressed the tab key.

Read more about this topic:  Content Assist

Famous quotes containing the word code:

    Hollywood keeps before its child audiences a string of glorified young heroes, everyone of whom is an unhesitating and violent Anarchist. His one answer to everything that annoys him or disparages his country or his parents or his young lady or his personal code of manly conduct is to give the offender a “sock” in the jaw.... My observation leads me to believe that it is not the virtuous people who are good at socking jaws.
    George Bernard Shaw (1856–1950)