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.
Architecting Drupal Modules           Report from the Frontlines
Ronald Ashri                   Directory of Technologyt: @ronald_istos
Ronald Ashri                   Directory of Technologyt: @ronald_istos
Ronald Ashri                   Directory of Technologyt: @ronald_istos
Ronald Ashri                   Directory of Technology                           actSMARTt: @ronald_istos
building modules                                                        path not always clear  drupal                     ...
example 1I want my module to use a javascript library
example 1                                      I want my module to use a javascript libraryhttp://drupal.org/node/304255Th...
example 1                                      I want my module to use a javascript libraryhttp://drupal.org/node/304255  ...
example 1I want my module to use a javascript library
example 1I want my module to use a javascript library
example 1I want my module to use a javascript library
http://www.flickr.com/photos/42302655@N02/4064741545
let’s take a step back                                                 what are we trying to do here                APIs (...
Building SoftwareMethodology, Framework, Patterns, Architecture
Building Software                             Methodology, Framework, Patterns, Architecture    Methodology    A set of gu...
Building Software                             Methodology, Framework, Patterns, Architecture    Methodology               ...
Building Software                             Methodology, Framework, Patterns, Architecture    Methodology               ...
Building Software                             Methodology, Framework, Patterns, Architecture    Methodology               ...
Building Software                             Methodology, Framework, Patterns, Architecture    Methodology               ...
Building Software                             Methodology, Framework, Patterns, Architecture    Methodology               ...
Building Software                             Methodology, Framework, Patterns, Architecture    Methodology               ...
Building Drupal Modules                             Methodology, Framework, Patterns, Architecture                        ...
example 2how should I structure my files?
example 2                     how should I structure my files?everything in the root of your moduledirectory
example 2                      how should I structure my files?everything in the root of your moduledirectory.module, .info...
example 2                      how should I structure my files?everything in the root of your moduledirectory.module, .info...
example 3how should I name my files
example 3                             how should I name my files.module, .info, .inc, .install, .test
example 3                             how should I name my files.module, .info, .inc, .install, .testoccasionaly throw in: ...
example 3                             how should I name my files.module, .info, .inc, .install, .testoccasionaly throw in: ...
example 3                             how should I name my files.module, .info, .inc, .install, .testoccasionaly throw in: ...
example 3                             how should I name my files.module, .info, .inc, .install, .testoccasionaly throw in: ...
example 4I need to store data
example 4                         I need to store datamy table via hook_schema + DBTNG
example 4                             I need to store datamy table via hook_schema + DBTNGentities are the way to go - alw...
example 4                             I need to store datamy table via hook_schema + DBTNGentities are the way to go - alw...
example 4                             I need to store datamy table via hook_schema + DBTNGentities are the way to go - alw...
Guidelineswhat is important in general
Guidelines                                   what is important in generalDrupal is a complex system of many interlinked pa...
Guidelines                                   what is important in generalDrupal is a complex system of many interlinked pa...
Guidelines                                   what is important in generalDrupal is a complex system of many interlinked pa...
Guidelineswhat is important in general
Guidelines                          what is important in generalSeparation of concerns - (e.g. logic inmodules, presentati...
Guidelines                          what is important in generalSeparation of concerns - (e.g. logic inmodules, presentati...
Guidelines                          what is important in generalSeparation of concerns - (e.g. logic inmodules, presentati...
Define Problem and Design     not in a Drupal specific way
Define Problem and Design                       not in a Drupal specific wayYou module solves a problem - you should beable ...
Define Problem and Design                         not in a Drupal specific wayYou module solves a problem - you should beabl...
Define Problem and Design                         not in a Drupal specific wayYou module solves a problem - you should beabl...
Define Problem and Design     not in a Drupal specific way
Define Problem and Design                         not in a Drupal specific wayDescribe your architecture in generic termsfirs...
Define Problem and Design                         not in a Drupal specific wayDescribe your architecture in generic termsfirs...
Define Problem and Design                         not in a Drupal specific wayDescribe your architecture in generic termsfirs...
Patterns - OO Patterns     Entity API, Subdomain
Patterns - OO Patterns                                    Entity API, SubdomainEntity API offers interfaces and implementa...
Patterns - OO Patterns                                    Entity API, SubdomainEntity API offers interfaces and implementa...
Patterns - OO Patterns                                    Entity API, SubdomainEntity API offers interfaces and implementa...
Patterns - Drupal Patterns            Views, Commerce
Patterns - Drupal Patterns                                    Views, CommerceSeparate UI from core module functionality
Patterns - Drupal Patterns                                    Views, CommerceSeparate UI from core module functionality  A...
Patterns - Drupal Patterns                                     Views, CommerceSeparate UI from core module functionality  ...
Patterns - Drupal Patterns                                     Views, CommerceSeparate UI from core module functionality  ...
Patterns - Service Patterns                     Rooms
Patterns - Service Patterns                                             RoomsWhere possible decouple interaction pointswit...
Patterns - Service Patterns                                             RoomsWhere possible decouple interaction pointswit...
Patterns - Service Patterns                                             RoomsWhere possible decouple interaction pointswit...
Patterns - Service Patterns                                             RoomsWhere possible decouple interaction pointswit...
in conclusion
in conclusionneed to work on methodology
in conclusionneed to work on methodologystart collecting and documentingpatterns
in conclusionneed to work on methodologystart collecting and documentingpatternsdiscuss conventions
in conclusionneed to work on methodologystart collecting and documentingpatternsdiscuss conventionstalk to me if intereste...
Upcoming SlideShare
Loading in …5
×

Architecting Drupal Modules - Report from the frontlines

2,937 views

Published on

How can we improve the quality of the Drupal modules developed and help new developers navigate their way through all the possible choices there are.

Published in: Technology
  • Be the first to comment

Architecting Drupal Modules - Report from the frontlines

  1. 1. Architecting Drupal Modules Report from the Frontlines
  2. 2. Ronald Ashri Directory of Technologyt: @ronald_istos
  3. 3. Ronald Ashri Directory of Technologyt: @ronald_istos
  4. 4. Ronald Ashri Directory of Technologyt: @ronald_istos
  5. 5. Ronald Ashri Directory of Technology actSMARTt: @ronald_istos
  6. 6. building modules path not always clear drupal youhttp://www.flickr.com/photos/hesketh/2249658529
  7. 7. example 1I want my module to use a javascript library
  8. 8. example 1 I want my module to use a javascript libraryhttp://drupal.org/node/304255The PHP function drupal_add_js() lets you add a JavaScript file,setting or inline code to the page and it takes 5 parameters (seethe api reference).
  9. 9. example 1 I want my module to use a javascript libraryhttp://drupal.org/node/304255 http://drupal.org/node/304255The PHP function drupal_add_js() lets you add a JavaScript file,setting or inline code to the page and it takes 5 parameters (seethe api reference).
  10. 10. example 1I want my module to use a javascript library
  11. 11. example 1I want my module to use a javascript library
  12. 12. example 1I want my module to use a javascript library
  13. 13. http://www.flickr.com/photos/42302655@N02/4064741545
  14. 14. let’s take a step back what are we trying to do here APIs (FAPI, DBTNG, ...) Hooks (Events)DRUPAL Library Functions (e.g. check_plain) Systems (Menu, Search, Node Access) MY MODULE
  15. 15. Building SoftwareMethodology, Framework, Patterns, Architecture
  16. 16. Building Software Methodology, Framework, Patterns, Architecture Methodology A set of guidelines / processes that accompanyyou from problem definition to solution
  17. 17. Building Software Methodology, Framework, Patterns, Architecture Methodology Framework A set of guidelines / Provides reusable elements processes that accompany and underlying structure youyou from problem definition plug into to solution
  18. 18. Building Software Methodology, Framework, Patterns, Architecture Methodology Framework A set of guidelines / Provides reusable elements processes that accompany and underlying structure youyou from problem definition plug into to solution Patterns Proven reusable solutions
  19. 19. Building Software Methodology, Framework, Patterns, Architecture Methodology Framework A set of guidelines / Provides reusable elements processes that accompany and underlying structure youyou from problem definition plug into to solution Patterns Proven reusable solutions Your Architecture Elements and relationships between them
  20. 20. Building Software Methodology, Framework, Patterns, Architecture Methodology Framework A set of guidelines / Provides reusable elements processes that accompany and underlying structure youyou from problem definition plug into to solution Patterns Proven reusable solutions Your Architecture Elements and relationships between them
  21. 21. Building Software Methodology, Framework, Patterns, Architecture Methodology Framework A set of guidelines / Provides reusable elements processes that accompany and underlying structure youyou from problem definition plug into to solution Patterns Proven reusable solutions Your Architecture Elements and relationships between them
  22. 22. Building Software Methodology, Framework, Patterns, Architecture Methodology Framework A set of guidelines / Provides reusable elements processes that accompany and underlying structure youyou from problem definition plug into to solution Patterns Proven reusable solutions Your Architecture Elements and relationships between them
  23. 23. Building Drupal Modules Methodology, Framework, Patterns, Architecture Drupal Methodology ? A set of guidelines / Framework Provides reusable elements processes that accompany and underlying structure youyou from problem definition plug into to solution Patterns ? Proven reusable solutions Your Drupal Module Architecture Elements and relationships
  24. 24. example 2how should I structure my files?
  25. 25. example 2 how should I structure my files?everything in the root of your moduledirectory
  26. 26. example 2 how should I structure my files?everything in the root of your moduledirectory.module, .info in root, images in images, jsin js, inc in includes, views in views
  27. 27. example 2 how should I structure my files?everything in the root of your moduledirectory.module, .info in root, images in images, jsin js, inc in includes, views in viewssome in root, some in directories based onhistory, module evolution, style changes,etc
  28. 28. example 3how should I name my files
  29. 29. example 3 how should I name my files.module, .info, .inc, .install, .test
  30. 30. example 3 how should I name my files.module, .info, .inc, .install, .testoccasionaly throw in: .theme, .install.inc
  31. 31. example 3 how should I name my files.module, .info, .inc, .install, .testoccasionaly throw in: .theme, .install.incsometimes: .<modulename>.<thing>.inc,ClassName.inc
  32. 32. example 3 how should I name my files.module, .info, .inc, .install, .testoccasionaly throw in: .theme, .install.incsometimes: .<modulename>.<thing>.inc,ClassName.incmyconventionisbetter.me
  33. 33. example 3 how should I name my files.module, .info, .inc, .install, .testoccasionaly throw in: .theme, .install.incsometimes: .<modulename>.<thing>.inc,ClassName.incmyconventionisbetter.meno! MyConventionIsBetter.class.inc
  34. 34. example 4I need to store data
  35. 35. example 4 I need to store datamy table via hook_schema + DBTNG
  36. 36. example 4 I need to store datamy table via hook_schema + DBTNGentities are the way to go - always!(maybe?)
  37. 37. example 4 I need to store datamy table via hook_schema + DBTNGentities are the way to go - always!(maybe?)fields, then a fieldgroup entity (or node)to add what you are missing
  38. 38. example 4 I need to store datamy table via hook_schema + DBTNGentities are the way to go - always!(maybe?)fields, then a fieldgroup entity (or node)to add what you are missingis your data content or configuration?
  39. 39. Guidelineswhat is important in general
  40. 40. Guidelines what is important in generalDrupal is a complex system of many interlinked partsThere are always many ways to skin a cat...
  41. 41. Guidelines what is important in generalDrupal is a complex system of many interlinked parts what the...?There are always many ways to skin a cat...
  42. 42. Guidelines what is important in generalDrupal is a complex system of many interlinked parts what the...?There are always many ways to skin a cat... It’s not about the recipes - it’s about the principles Guidelines + Patterns
  43. 43. Guidelineswhat is important in general
  44. 44. Guidelines what is important in generalSeparation of concerns - (e.g. logic inmodules, presentation that can fully bymanaged by themes, flexible admin)
  45. 45. Guidelines what is important in generalSeparation of concerns - (e.g. logic inmodules, presentation that can fully bymanaged by themes, flexible admin)Decoupled - more smaller modules thatincrementally add functionality, OO wherepossible
  46. 46. Guidelines what is important in generalSeparation of concerns - (e.g. logic inmodules, presentation that can fully bymanaged by themes, flexible admin)Decoupled - more smaller modules thatincrementally add functionality, OO wherepossibleConsistent - similar things always happen andare described in the same way
  47. 47. Define Problem and Design not in a Drupal specific way
  48. 48. Define Problem and Design not in a Drupal specific wayYou module solves a problem - you should beable to describe that in generic terms.
  49. 49. Define Problem and Design not in a Drupal specific wayYou module solves a problem - you should beable to describe that in generic terms. A hotel owner needs to be able to display a list of available rooms with their associated descriptions given an arrival and departure date
  50. 50. Define Problem and Design not in a Drupal specific wayYou module solves a problem - you should beable to describe that in generic terms. A hotel owner needs to be able to display a list of available rooms with their associated descriptions given an arrival and departure date Vs: I need to get all bookable unit entities and attach a field entity reference to them pointing to Room Description nodes that I can then render in Rooms view mode
  51. 51. Define Problem and Design not in a Drupal specific way
  52. 52. Define Problem and Design not in a Drupal specific wayDescribe your architecture in generic termsfirst and then in specific Drupal terms
  53. 53. Define Problem and Design not in a Drupal specific wayDescribe your architecture in generic termsfirst and then in specific Drupal terms Allows you to focus on what’s important and not get distracted by how Drupal does things
  54. 54. Define Problem and Design not in a Drupal specific wayDescribe your architecture in generic termsfirst and then in specific Drupal terms Allows you to focus on what’s important and not get distracted by how Drupal does things Enables you to better choose what Drupal way to use subsequently
  55. 55. Patterns - OO Patterns Entity API, Subdomain
  56. 56. Patterns - OO Patterns Entity API, SubdomainEntity API offers interfaces and implementation ofthose interfaces as well as helper “procedural” stylefunctions
  57. 57. Patterns - OO Patterns Entity API, SubdomainEntity API offers interfaces and implementation ofthose interfaces as well as helper “procedural” stylefunctionsSubdomain offers all of its core functionality via aclass - you can extend/replace via your own module
  58. 58. Patterns - OO Patterns Entity API, SubdomainEntity API offers interfaces and implementation ofthose interfaces as well as helper “procedural” stylefunctionsSubdomain offers all of its core functionality via aclass - you can extend/replace via your own module Allows us to plug into “known” generic ways of doing things - reduces the burden of Drupal to define new styles
  59. 59. Patterns - Drupal Patterns Views, Commerce
  60. 60. Patterns - Drupal Patterns Views, CommerceSeparate UI from core module functionality
  61. 61. Patterns - Drupal Patterns Views, CommerceSeparate UI from core module functionality Allows us to focus on each and replace
  62. 62. Patterns - Drupal Patterns Views, CommerceSeparate UI from core module functionality Allows us to focus on each and replace Form submit handlers, etc should use you “core engine” functions - avoid stuffing a lot of logic there
  63. 63. Patterns - Drupal Patterns Views, CommerceSeparate UI from core module functionality Allows us to focus on each and replace Form submit handlers, etc should use you “core engine” functions - avoid stuffing a lot of logic there Can switch UI off for performace gains
  64. 64. Patterns - Service Patterns Rooms
  65. 65. Patterns - Service Patterns RoomsWhere possible decouple interaction pointswithin same module
  66. 66. Patterns - Service Patterns RoomsWhere possible decouple interaction pointswithin same module Rooms produces all availability data in JSON following a callback
  67. 67. Patterns - Service Patterns RoomsWhere possible decouple interaction pointswithin same module Rooms produces all availability data in JSON following a callback Allows us to use any number of display techinques such as the FullCalendar JS library
  68. 68. Patterns - Service Patterns RoomsWhere possible decouple interaction pointswithin same module Rooms produces all availability data in JSON following a callback Allows us to use any number of display techinques such as the FullCalendar JS library Can easily abstract and connect to non- Drupal site
  69. 69. in conclusion
  70. 70. in conclusionneed to work on methodology
  71. 71. in conclusionneed to work on methodologystart collecting and documentingpatterns
  72. 72. in conclusionneed to work on methodologystart collecting and documentingpatternsdiscuss conventions
  73. 73. in conclusionneed to work on methodologystart collecting and documentingpatternsdiscuss conventionstalk to me if interested - @ronald_istos

×