2. René Winkelmeyer
Senior Consultant
midpoints GmbH
http://www.midpoints.de
IBM Advanced Business Partner
IBM Design Partner
Services
• Notes / Domino Consulting
• E-Mail Management
• Mobile
Products
• IBM Notes Traveler planning & deployment
• mobile app development
• Domino based iOS Device Management
• Domino based “Dropbox” for Notes and iOS
About me
3. René Winkelmeyer
Senior Consultant
• Skype
muenzpraeger
• Twitter
muenzpraeger
• LinkedIn
muenzpraeger
• Slideshare
muenzpraeger
• Web
http://blog.winkelmeyer.com
http://www.midpoints.de
• Mail
mail@winkelmeyer.com
rene.winkelmeyer@midpoints.de
OpenNTF
• File Navigator
• Generic NSF View Widget for IBM Connections
About me
4. 4
What’s this session about?
§ This session is about Java and Eclipse.
§ The goal is to make your life as an developer easier.
§ Most of the content can be applied to Java in Domino and to Domino
Designer.
§ The views are my own – yours may be different. ;-)
5. Tip #1:
Don’t return NULL values
§ Returning NULL from your own methods is a bad behavior.
§ Forces people to doublecheck for NULL and values.
§ Instead return something „empty“ or your own „NULL“.
7. 7
Tip #2:
Use the Eclipse Marketplace for IDE enhancements
§ Thousands of helpful (and sometimes not helpful) addons are
available for Eclipse
§ Just go to the Eclipse Marketplace and search for your favorite term
8. 8
Tip #3:
Style your Editor like you want
§ People have different opinions on which kind of text display is better
(for their eyes)
§ Black text on white background
§ White text on black background
§ Colored text on white background
§ Colored text on black background
§ xxx text on xxx background
9. 9
Tip #3:
Style your Editor like you want
§ The „Eclipse Color Theme“ plug-in comes to your rescue.
§ Different color codings (background, text etc.) for different
editors within Eclipse
12. 12
Tip #4:
Easy access to the files of your projects
§ „StartExplorer“ give you the capability to access the physical files
of your Java project directly from within the IDE.
13. 13
Tip #4:
Easy access to the files of your projects
§ Open shell at the file/folder location
§ Open Explorer/Finder/Nautilus etc at the file/folder location
§ Execute custom commands against the file/folder
15. 15
Tip #5:
Intelligent Code recommendation
§ Replace the built-in content assist with „Code Recommenders“ –
and learn how others use and built code.
16. 16
Tip #5:
Intelligent Code recommendation
§ „Favorites“ at the top of the new content assist show you what
others have mostly used.
20. 20
Tip #7:
Ease code comment generation
§ Option 1: Write /** at the top of a method and press ENTER.
21. 21
Tip #7:
Ease code comment generation
§ Option 2: Auto-generate comments for selected elements
22. 22
Tip #8:
Don’t document your code for documentation purposes
§ Good documentation describes why the code is doing what is does
– not what it‘s doing.
23. 23
Tip #8:
Don’t document your code for documentation purposes
§ Good documentation describes why the code is doing what is does
– not what it‘s doing.
24. 24
Tip #9:
Code styling – for projects and workspaces
§ Having a similar pattern for „how code looks like“ makes it easier to
read, understand and maintain.
§ That‘s even more essential when working in a team.
28. 28
Tip #10:
Awesome “Reflection”s
§ Reflection is the ability to make modifications at runtime by making
use of Type Introspections.
§ i. e. it allows you to add a JAR at runtime even if it‘s not in the
classpath
§ „setAccessible“ is for men, not for boys!
29. 29
Tip #11:
Type-safe Enumerations
§ Enumerations (or short: enums) are a rock-solid alternative to the
commonly used static int or String constants.
33. 33
Tip #12:
Use Buffered streams for I/O operations
§ Use Buffered streams for I/O operations whenever possible.
§ Unbuffered streams
§ Read and write is handled by the OS directly, which may lead to
heavy disk usage
§ Buffered streams
§ Read and write is handled in-memory
35. 35
Tip #13:
Singleton – instance
§ Singletons are bad. Some people say. Others really like them.
§ The main use case for a Singleton is to have data available across
classes. Think „global“.
36. 36
Tip #13:
Singleton – instance
§ Instantiated at the first call. Really handy if you run multi-threaded or
concurrent access against the same data.
40. 40
Tip #15:
Serialize and Deserialize
§ Serialization allows you to store (serizalizable) Objects in a JVM-
independent way.
§ It‘s a byte representation of the objects type and the objects data.
§ The object needs to implement java.io.Serializable.
47. 47
Tip #17:
Transform to HTML-escaped characters
§ Had ever the need to convert (special) characters to HTML encoded
strings?
§ Several 3rd party libraries (i. e. Apache) are available for that.
§ Leverage the built-in capabilities. A „char“ is represented as a
number. So it‘s an easy one to encode that one.
49. 49
Tip #18:
Pass „unlimited“ objects as method arguments
§ Pass „unlimited“ objects as method values just by adding „...“ to the
end of the class name.
50. 50
Tip #19:
Accessing localized ressources
§ If you localize your applications make your that you can easily
access it by placing it in your package.
51. 51
Tip #20:
Edit your properties properly escaped
§ Working with localization could be very interesting. Different
charsets in different languages.
§ Those localized files are normally placed in files like
„messages_nl.properties“, „messages_de.properties“ and so on.
52. 52
Tip #20:
Edit your properties properly escaped
§ For a proper display they need to be converted to ASCII.
§ One easy way is to convert them via the built-in tool „native2ascii“.
The binary is located within the /bin folder of your Java distribution.
53. 53
Tip #20:
Edit your properties properly escaped
§ An alternative approach is to use the „Properties Editor“ plugin.
§ It converts the text to ASCII when you save the file!
54. 54
Tip #21:
Use “finally” for cleaning up
§ „finally“ you can clean up.
§ Think about closing I/O connections, recycle Domino objects etc.
57. 57
Tip #23:
Debug Detail formatters give you value insights
§ Inspecting current object and variable values while debugging code
is one of the big benefits using Eclipse.
§ Change your variables and/or issue commands/methods against
them.
§ It applies also to Domino Java objects!
60. 60
Tip #24:
Recycle, recycle, recycle
§ Recycling is important in Domino!
§ Recycling is important in Domino!
§ Recycling is important in Domino!
§ Recycling is important in Domino!
§ Recycling is important in Domino!
§ Recycling is important in Domino!
§ Recycling is important in Domino!
61. 61
Tip #24:
Recycle, recycle, recycle
§ Free‘ing the Cpp-Handle is critical, as ressources are limited on the
server.
§ Free‘ing the parent normally frees the children.
§ Keep your house clean, i. e. always recycle EmbeddedObjects.
62. 62
Tip #24:
Recycle, recycle, recycle
§ Running a NSD gives you insights of the currently used backend
handles.
§ If you‘re still on 8.5.2 => Upgrade!
63. 63
Tip #25:
Exceptions are not for control-flow
§ Use Exceptions for stuff you can recover and for unexpected
conditions.
66. 66
Tip #26:
Typed vs. Un-Typed Collections
§ Typed collections make your life much more easier.
§ You see in the code what type it is.
§ No need for casting
§ Easier for looping (instead of using an iterator)
69. 69
Tip #27:
Don’t concatenate too much
§ Even if it‘s convenient – try to avoid „too much“ method
concatenation.
§ Makes your life a lot easier, especially during development and
debugging.
71. 71
Tip #28:
Accessible fields
§ Fields should always be private except for constants
§ Accessible fields cause tight coupling
§ They are corruptible
§ If a field needs to be accessed => use „Getter“ and „Setter“