Northumberland Sunrise Rotary Club 2013-2014. Engage Rotary ~ Change Lives 2013-2014 Theme.
engage 2014 - JavaBlast
-
Upload
rene-winkelmeyer -
Category
Technology
-
view
193 -
download
1
Transcript of engage 2014 - JavaBlast
JavaBlast
engage 2014
René Winkelmeyer midpoints GmbH
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
René Winkelmeyer Senior Consultant
• Skype
muenzpraeger • Twitter
muenzpraeger • LinkedIn
muenzpraeger • Slideshare
muenzpraeger
• Web http://blog.winkelmeyer.com http://www.midpoints.de
• Mail [email protected] [email protected]
OpenNTF • File Navigator • Generic NSF View Widget for IBM Connections
About me
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. ;-)
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“.
Tip #1: Don’t return NULL values
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
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
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
10
Tip #3: Style your Editor like you want
§ Header
§ Content
11
Tip #3: Style your Editor like you want
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
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
14
Tip #4: Easy access to the files of your projects
15
Tip #5: Intelligent Code recommendation
§ Replace the built-in content assist with „Code Recommenders“ – and learn how others use and built code.
16
Tip #5: Intelligent Code recommendation
§ „Favorites“ at the top of the new content assist show you what others have mostly used.
17
Tip #5: Intelligent Code recommendation
18
Tip #5: Intelligent Code recommendation
19
Tip #6: Use meaningful names in your code
§ Use meaningful names – ‘nuff said.
20
Tip #7: Ease code comment generation
§ Option 1: Write /** at the top of a method and press ENTER.
21
Tip #7: Ease code comment generation
§ Option 2: Auto-generate comments for selected elements
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
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
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.
25
Tip #9: Code styling – for projects and workspaces
26
Tip #9: Code styling – for projects and workspaces
27
Tip #9: Code styling – for projects and workspaces
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
Tip #11: Type-safe Enumerations
§ Enumerations (or short: enums) are a rock-solid alternative to the commonly used static int or String constants.
30
Tip #11: Type-safe Enumerations
31
Tip #11: Type-safe Enumerations
32
Tip #11: Type-safe Enumerations
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
34
Tip #12: Use Buffered streams for I/O operations
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
Tip #13: Singleton – instance
§ Instantiated at the first call. Really handy if you run multi-threaded or concurrent access against the same data.
37
Tip #13: Singleton – instance
38
Tip #14: The Builder pattern
§ A Builder gives you the capability to wrap complex objects into a fluent interface.
39
Tip #14: The Builder pattern
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.
41
Tip #15: Serialize and Deserialize
42
Tip #15: Serialize and Deserialize
43
Tip #16: Find Your Bugs
§ Employ good coding practises (and find bad ones) using „FindBugs“ from the Eclipse Marketplace.
44
Tip #16: Find Your Bugs
45
Tip #16: Find Your Bugs
§ You‘ll see the output right within your IDE.
46
Tip #16: Find Your Bugs
§ You‘ll see the output right within your IDE.
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.
48
Tip #17: Transform to HTML-escaped characters
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
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
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
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
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
Tip #21: Use “finally” for cleaning up
§ „finally“ you can clean up.
§ Think about closing I/O connections, recycle Domino objects etc.
55
Tip #21: Use “finally” for cleaning up
56
Tip #22: Debugging is simple – just do it
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!
58
Tip #23: Debug Detail formatters give you value insights
59
Tip #23: Debug Detail formatters give you value insights
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
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
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
Tip #25: Exceptions are not for control-flow
§ Use Exceptions for stuff you can recover and for unexpected conditions.
64
Tip #25: Exceptions are not for control-flow
65
Tip #25: Exceptions are not for control-flow
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)
67
Tip #26: Typed vs. Un-Typed Collections
68
Tip #26: Typed vs. Un-Typed Collections
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.
70
Tip #27: Don’t concatenate too much
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“
72
Tip #28: Accessible fields
73
Tip #29: Keep code clean
§ Delete not-needed / „out-commented“ code
§ Your SCM takes care of the history.
74
Thank you very much!