Friday, June 22, 2007

Why do developers need Code-Snippets

Many of you may already have noticed that we started a Snippet collection for JFace-Elements like the one you know from SWT. Yesterday I updated the wiki-page to show all snippets with a short description.

Are Snippets only something we provide because we love our users soooo much? To me the answer is no.

There are multiple reasons why snippets are a great thing:

  • Help for users to get started easily (Users)

  • Useful templates for users to log bugs (Users/Developers)
    Without a reproduceable testcase it is very hard to track bugs. Be prepared that JFace-Devs will insist even more on Snippets because now you have starting points to create Snippets easily. Insisting on snippets we often found out that we are not the one to blame but someone different (including the bugreporter itself)

  • Useful to mark bugs as invalid (Developers)

  • Useful to check no regressions are introduced (Developers)
    We also added snippets to our collection although their Classes are deprecated because this way we had an easy test case that we don't break any backwards contract. In our case we did this for TableTreeViewer

  • Development example for new features (Developers)
    A good example is Snippet026 which was used to develop Cell-Navigation and Editor-Activation throughout the whole 3.3 cycle.

  • Advertise new API

3 comments:

Ilya Shinkarenko said...

Thank you Tom for the post. JFace snippets collection seems to be very interesting is definitely useful for Eclipse newcomers.

Tom Seidel said...

Hi Tom. Small node:
The german flag in http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet010OwnerDraw is not correct ;)

Christophe Cornu said...

Thanks Tom!
All you've said about snippets are so true... In addition snippets are a good way during development to filter out bad new API. If the snippet feels ugly, the new API is probably just not 'right' yet.
Now how can we encourage other components to expose snippets too? With your work maybe we can now close
bug 176610