Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

APEX Bad Practices

We all make mistakes. Making mistakes is an opportunity to learn. But as a first step you have to recognize the mistakes you made.
If you don't, those mistakes might evolve into a practice. A bad practice.
But you can also learn from someone else's mistakes.
That's why I crowdsourced "Bad Practices" that people have encountered in the wild.
And I was suprised by the numerous examples people came up with.
So this session will cover real world examples of practices that are labeled as "bad".
Of course we will discuss why these practices are bad and what would be the better solution.

  • Be the first to comment

  • Be the first to like this

APEX Bad Practices

  1. 1. Copyright © 2019 APEX Consulting APEX Bad Practices
  2. 2. <bragging>
  3. 3. </bragging>
  4. 4. 3 Membership Tiers • Oracle ACE Director • Oracle ACE • Oracle ACE Associate bit.ly/OracleACEProgram 500+ Technical Experts Helping Peers Globally Connect: Nominate yourself or someone you know: acenomination.oracle.com @oracleace Facebook.com/oracleaces oracle-ace_ww@oracle.com
  5. 5. Get organised Dude, where’s my code? And what about JavaScript … Miscellaneous
  6. 6. Get organised
  7. 7. Naming stuff
  8. 8. Need a Page Item Value on other pages? Use an Application Item Use P0_EMPNO Use P1_EMPNO
  9. 9. $(“#P1_EMPNO”)apex.item(“P1_EMPNO”)
  10. 10. Divide and conquer
  11. 11. A few Applications with a lot of Pages
  12. 12. A lot of Applications with a few Pages
  13. 13. MASTER SEED subscription APP 1 APP 2 APP 3 copy subscription subscription subscription
  14. 14. ✅ ❌ ❔ ❌ ❌ ❌ ❌ ✅ ✅ ✅ ❌ ❌ ❌ ✅ ✅ ✅ ❌ ❌ ❌ ❌ ❌ ❌ ❌ ✅ ❌ ✅ ❌ ✅ ✅ ❌ ❌ ❌ ❌ ❌ ❌
  15. 15. Page 0
  16. 16. Unsubscribe
  17. 17. NEVER Unsubscribe
  18. 18. Don’t put your files in the APEX directories
  19. 19. /usr/local/tomcat/webapps/i
  20. 20. /usr/local/tomcat/webapps/ mycode /mycode/js/myJsFile.js
  21. 21. Get organised Dude, where’s my code? And what about JavaScript … Miscellaneous
  22. 22. Get organised Dude, where’s my code? And what about JavaScript … Miscellaneous
  23. 23. Dude, where’s my code?
  24. 24. Process Region / Item Source Condition Read Only Condition Item Default Dynamic Action Validation Where CAN you put your PL/SQL?
  25. 25. Where SHOULD you put your PL/SQL? Reusable Testable Compiled Dependencies
  26. 26. Some more remarks regarding PL/SQL
  27. 27. select * from my_big_table where field = v('P2_EMPNO')
  28. 28. select * from my_big_table where field = ( select v('P2_EMPNO') from dual )
  29. 29. with param as ( select v('P2_EMPNO') empno from dual ) select * from my_big_table , param where field = param.empno
  30. 30. with param as ( select /*+ MATERIALIZE */ v('P2_EMPNO') empno from dual ) select * from my_big_table , param where field = param.empno
  31. 31. FORMAT MASK
  32. 32. render / submit / ajax
  33. 33. Beware of undocumented features
  34. 34. APEX 5 APEX 18 :APXWS_SEARCH_STRING_1 :APXWS_EXPR_1 :apex$f1 https://roelhartman.blogspot.com/2016/07/prevent-general-row-based-search-in.html
  35. 35. Get organised Dude, where’s my code? And what about JavaScript … Miscellaneous
  36. 36. Get organised Dude, where’s my code? And what about JavaScript … Miscellaneous
  37. 37. And what about JavaScript …
  38. 38. Page “JavaScript section” Page header / footer Region header / footer Item Pre / Post Text URL target Dynamic Action When / Condition DA Action : Execute JavaScript Code Where CAN you put your JavaScript?
  39. 39. Where SHOULD you put your JavaScript? In a file (on your network / static app file) (reference in the User Interface Details) In a Plugin (JavaScript file) Roels Rule : No JavaScript anywhere else
  40. 40. The code is more what you'd call "guidelines" than actual rules
  41. 41. How should you code your JavaScript? $(“#P1_EMPNO”) or apex.item(“P1_EMPNO”)
  42. 42. How should you code your JavaScript? $v(“#P1_EMPNO”) or apex.item(“P1_EMPNO”).getValue()
  43. 43. How should you code your JavaScript? $v(“P1_EMPNO”) or apex.item(“P1_EMPNO”).getValue()
  44. 44. Know your APEX JavaScript API’s https://docs.oracle.com/en/database/oracle/application-express/19.1/aexjs/index.html
  45. 45. Beware of undocumented features
  46. 46. gReport
  47. 47. htmldb_Get
  48. 48. A lot of stuff in the Interactive Grid
  49. 49. Watch your plugins …
  50. 50. Beware of undocumented features
  51. 51. Beware of DOCUMENTED features
  52. 52. function render ( p_dynamic_action in apex_plugin.t_dynamic_action , p_plugin in apex_plugin.t_plugin ) return apex_plugin.t_dynamic_action_render_result is l_result apex_plugin.t_dynamic_action_render_result; begin l_result.javascript_function := 'function(){ openModal( this.affectedElements[0].id ); }'; return l_result; end;
  53. 53. function render ( p_dynamic_action in apex_plugin.t_dynamic_action , p_plugin in apex_plugin.t_plugin ) return apex_plugin.t_dynamic_action_render_result is l_result apex_plugin.t_dynamic_action_render_result; begin l_result.javascript_function := 'function(){ openModal( this.affectedElements[0].id ); }'; return l_result; end;
  54. 54. function render ( p_dynamic_action in apex_plugin.t_dynamic_action , p_plugin in apex_plugin.t_plugin ) return apex_plugin.t_dynamic_action_render_result is l_result apex_plugin.t_dynamic_action_render_result; begin l_result.javascript_function := 'function({ apex.theme.openRegion( this.affectedElements[0].id ); }'; return l_result; end;
  55. 55. Get organised Dude, where’s my code? And what about JavaScript … Miscellaneous
  56. 56. Get organised Dude, where’s my code? And what about JavaScript … Miscellaneous
  57. 57. Miscellaneous
  58. 58. Dynamic Actions are cool
  59. 59. Page Process / Computation
  60. 60. Region refresh Page refresh Row refresh
  61. 61. function render ( p_dynamic_action in apex_plugin.t_dynamic_action , p_plugin in apex_plugin.t_plugin ) return apex_plugin.t_dynamic_action_render_result is l_result apex_plugin.t_dynamic_action_render_result; begin l_result.javascript_function := 'function(){ var myGrid = apex.region( this.affectedElements[0].id ) .widget().interactiveGrid("getViews").grid; myGrid.model.fetchRecords( myGrid.getSelectedRecords() ); }'; return l_result; end;
  62. 62. Get organised Dude, where’s my code? And what about JavaScript … Miscellaneous
  63. 63. Copyright © 2019 APEX Consulting Q& A@roelh roel@apexconsulting.nl http://www.apexconsulting.nl
  64. 64. @roelh roel@apexconsulting.nl http://www.apexconsulting.nl Copyright © 2019 APEX Consulting

×