ADF Worst Practices (UKOUG Tech2013)

6,931 views

Published on

Presentation from UKOUG Tech13 conference on Worst Practices for Developing an ADF Application.
This is a collection of worst practices and lessons to be learned collected by Steven Davelaar and Wilfred van der Deijl

Published in: Technology
2 Comments
16 Likes
Statistics
Notes
  • Request scope is okay. The problem here is that you hold on to an AM for longer than a single request and that particular AM instance might be re-used for some other session and you can get another instance on the next request. This is why holding on to the current AM is bad.
    By the way: getting the AM from a Managed Bean should be avoided whenever possible. You're breaking the ADF binding abstraction layer by 'poking through' it.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Regarding page 36 (Extreme disastrous caching):

    Is this specific to the Page Flow Scope or is that just an extreme form of the error. In particular would this code be OK on a Request Scope Bean?

    Are there any project design patterns in which this code would be OK?

    We have a root AM structure. Does that matter?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
6,931
On SlideShare
0
From Embeds
0
Number of Embeds
80
Actions
Shares
0
Downloads
311
Comments
2
Likes
16
Embeds 0
No embeds

No notes for slide

ADF Worst Practices (UKOUG Tech2013)

  1. 1. S Worst Practices for Developing an ADF Application UKOUG ADF EMG Version 12.1.2.3.4.0.0b Build WORST_PRACTICES_12.1.2.3.4.0.0b_UKOUG_2013 ADF EMG
  2. 2. S About us Paco van der Linden AMIS www.adfplus.com @pavadeli Wilfred van der Deijl The Future Group www.redheap.com @wilfreddeijl
  3. 3. S About us Steven Davelaar Oracle ateam-oracle.com @stevendavelaar Wilfred van der Deijl The Future Group www.redheap.com @wilfreddeijl
  4. 4. S Ideal project ● 1 developer That’s you of course!
  5. 5. S Threats to a healthy ADF project ● Customer / Business / Functional designer ● Architect ● Project manager
  6. 6. S Threats to a healthy ADF project ● Customer / Business / Functional designer ● Architect ● Project manager ● Other developers ● Graphic designer
  7. 7. S Other Developers… Are not a member of ADF EMG
  8. 8. S Other Developers… Do not use ADF EMG Taskflow Tester
  9. 9. S ADF EMG Taskflow Tester - Wiki
  10. 10. S ADF EMG Taskflow Tester
  11. 11. S Other Developers… Don’t add ADF Source code library ● How to get ADF Source ○ ○ ○ ○ ○ ○ Go to support.oracle.com Log Service Request for JDeveloper/ADF “ADF Source Code Request” as problem type Sign agreement and upload to SR Get access to ZIP, typically within one day New versions don’t need new agreement ● Allows debugging of ADF framework
  12. 12. S Other Developers… Don’t add ADF Source code library
  13. 13. S Other Developers… Don’t adhere to ADF Code Guidelines
  14. 14. S ADF Code Guidelines ● 38 pages of excellent content by ADF guru’s ● Topics include: ○ ○ ○ ○ ○ ○ ○ ○ General Code Guidelines ADF Business Components ADF Faces ADF TaskFlows ADF Binding Layer Security High Availability … and more
  15. 15. S Other developers ● Don’t adhere to your project specific coding guidelines ● Other developers need your help ○ Reserve time to review each other’s version control commits ○ You might learn from their code as well!! ● Reserve time to perform QA checks ○ Against ADF coding guidelines and project specific guidelines ○ ...or automate this ■ come back tomorrow 10:15 - Exchange 6 “Quality Assurance with JDev Auditing Framework”
  16. 16. W Threats to a healthy ADF project ● Customer / Business / Functional designer ● Architect ● Project manager ● Other developers ● Graphic designer
  17. 17. W
  18. 18. W
  19. 19. W
  20. 20. W
  21. 21. W
  22. 22. W
  23. 23. W Graphic designer - Pitfalls ● Website ≠ Application ● “HTML is for semantics, CSS is for layout…” ○ ADF Fragment ≠ HTML, ADF skin ≠ CSS ○ ADF Skin → primarily colours, ADF Fragment → the rest ● Bad practice: CSS for layout management
  24. 24. W ADF Skinning Tips ● Use stand-alone Skin Editor ● Use ADF component selectors ○ don’t look at the generated HTML ○ use ADF Faces Skin Selectors Tag Reference ● Choice ○ UI Designer to learn ADF skinning (preferred choice) ○ ADF developer to learn CSS
  25. 25. W How to Write Code
  26. 26. W Logging ● Bad practice: System.err.println() ● Best practice: ADFLogger ○ ○ ○ ○ Configure at Runtime without restart Analyze Log for Performance Time your own code Better insight into ADF Framework internals
  27. 27. W ADFLogger - Runtime Configuration
  28. 28. W ADFLogger - Runtime Configuration
  29. 29. W ADFLogger - Log Analyzer ...or open log file from other (production) server
  30. 30. W Time custom code with ADFLogger::begin and ADFLogger::end bit.ly/adflogger
  31. 31. S Understanding ADF Layers ● Bad: code ADF applications like open source frameworks ● What do we mean by that? ○ All application state is kept in ViewController: ○ Lots of data queried from ADF BC and stored in JSF managed beans or entries in JSF memory scope maps ○ State passed back to ADF BC on subsequent requests: AM methods with lots of arguments ● Good: leverage ADF BC Active Data Model ○ Easy access to previously entered data ○ Row Currency management
  32. 32. S Understanding ADF Layers ● Signs of ViewController doing ADF BC work ○ import oracle.jbo… ○ Iterating RowSets ○ Storing lots of data in memory scopes or managed beans. Should only contain true UI state ○ Calling ApplicationModule methods with lots of arguments even when using binding layer ● Project Audits often show 50-80% of ViewController code is unnecessary ○ Either completely redundant ○ ...or should be moved to ADF BC layer
  33. 33. S ADF Faces a.k.a. the ViewController project
  34. 34. S ADF Lifecycle - Immediate property ● Bad: I run into issues, let’s try immediate=true ● Big difference: immediate on input component vs input on command component ● Almost always wrong in input components ● Make sure you understand both JSF lifecycle and ADF Optimized Lifecycle ● Steven Davelaar’s 18 Lessons ○ also available as ADF Insider Video bit.ly/jsf-lifecycle
  35. 35. S Know your ADF Memory Scopes ● Bad: Overuse of SessionScope & PageFlowScope ● Can have significant impact on mem usage ● Good: The smaller, the better ● Do not cache shorter living objects ○ Should be cheap to request each time when needed ○ Can have disastrous consequences, for example caching binding objects
  36. 36. S Extreme Disastrous Caching
  37. 37. S Extreme Disastrous Caching
  38. 38. S Memory Scopes Guidelines ● SessionScope ○ only use for user context ○ often (UTF) PageFlowScope is better ■ Two browser tabs share SessionScope but have independent UTF PageFlowScope ● RequestScope ○ often BackingBeanScope is better ○ each ADF Region or Declarative Component has own BackingBeanScope but share RequestScope ● Bad: Accessing SessionScope beans from BTF ○ BTF should be reusable and not rely on SessionScope ○ taskflow parameters are there for a reason
  39. 39. W tion olu “My ADF application is memoryhhungry” es a l) p al ave th We igh m (sm a of t rt
  40. 40. W JSF Component Binding JDeveloper Generated Code <af:inputText binding=”#{pageFlowScope.MyBean.lastName}”/>
  41. 41. W JSF Component Binding ● First ask yourself if it is really needed ● binding=”#{pageFlowScope.MyBean.lastName}” references UIComponent in PageFlow bean ● UIComponents should be released after each request ● But Managed Bean might require PageFlowScope for its functionality
  42. 42. W JSF Component Binding ComponentReference Enhancement Request logged
  43. 43. W “My JSF Component seems to travel around”
  44. 44. W Building Component Tree binding attribute No create component Not Null use component Yes call getter Null create component call setter bit.ly/compbind
  45. 45. W ADF Business Components a.k.a. the Model project
  46. 46. S ADF BC Data Model - Master Detail Beware of excessive querying Navigate row here... Requery (if populated)
  47. 47. S ADF BC Data Model - Master Detail Prevent excessive querying ● Use top level ViewObject instances with bind variables ● or reset detail ViewObject on master row navigation bit.ly/masterdetail
  48. 48. S ADF BC Data Model - Master Detail Prevent excessive querying
  49. 49. W “I encountered a dramatic ADF bug!!! Sometimes users lose entered data when the application is under heavy load.”
  50. 50. W Disable Application Module Pooling
  51. 51. W Don’t Simply passivate all!
  52. 52. W “ADF has huge performance problems!!! When under heavy load requests can take several minutes.” “Besides, what is this PS_TXN table for? It is eating up our tablespace.”
  53. 53. W Don’t Simply Passivate All ● Every ViewRow with transient atts is persisted ● During activation all state is applied
  54. 54. W Simply passivate all? No! ○ Every ViewRow with transient atts is persisted ○ During activation all state is applied
  55. 55. S What is passivated? ○ Set logger: oracle.jbo.server.Serializer ○ To:
  56. 56. W What is passivated? ○ Set logger: oracle.jbo.server.Serializer ○ To:
  57. 57. W “My ADF application is hacked!!! Sometimes users see data from other sessions.” “By the way, I did test the application with AM pooling off.”
  58. 58. W Application Module Recycling Not Losing, but Leaking state ● AM Instances Recycled for other users under load ● Not detected by disabling AM pooling!
  59. 59. W Detecting State Leakage
  60. 60. W Default AM Pool Tuning
  61. 61. W Default ViewObject Tuning
  62. 62. W Eclipse Memory Analyzer Tool bit.ly/eclipsemat
  63. 63. W Eclipse Memory Analyzer Tool (MAT) ● Make heap dump of running server JDK_HOME/bin/jmap -dump:file=path jvm_process_id ● ● ● ● Download and run standalone Eclipse MAT Inspect all objects in heap Query Heap Objects Predefined Reports and Tools bit.ly/eclipsemat
  64. 64. W Java Mission Control bit.ly/miscontrol
  65. 65. W Java Mission Control ● ● ● ● Any version of JRockit Hotspot (aka Sun JVM) since 1.7.0_40 Record a period of time Analyze ○ ○ ○ ○ ○ CPU performance Memory Usage Garbage Collection Thread Concurrency etcetera
  66. 66. W Miscellaneous
  67. 67. W Password management ● Bad: Credentials in clear text (eg. web.xml) ● Worse: Override with deployment plans bit.ly/secure-adf
  68. 68. W Reading Credential Store bit.ly/secure-adf
  69. 69. S Load/Stress Testing ● 5 developers on a Friday afternoon: “Ready…. Set…. Go” ● Every ADF project initially has performance issues ● Consider ○ JMeter - Free open source, not optimized for ADF ○ Oracle Application Testing Suite - ADF aware ● Requires ○ Production like testing environment ○ Good knowledge of chosen test tool ○ 10 days setup (assuming test tool experience)
  70. 70. S Further Reading ● bit.ly/adflogger ○ ADFLogger Custom Timings ● bit.ly/secure-adf ○ FMW Credential Store ● bit.ly/eclipsemat ○ Memory Analyzer Tool ● bit.ly/miscontrol ○ Java Mission Control ● bit.ly/jsf-lifecycle ○ Steven Davelaar’s JSF Lifecycle Lessons ● bit.ly/compbind ○ JSF Component Bindings ● bit.ly/masterdetail ○ Lazy Master Detail Query
  71. 71. S That’s all folks!

×