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