R.E.A.D How to select the right modules https://2015.midcamp.org/node/34 MidCamp 2015 #MidCamp

Who You Are New to Drupal. Want to improve habits. Session curious.

Your Role A Drupal developer. A site architect. Functionality decision maker.

What it is all About How to quickly make smart, informed functionality decisions.

What we will Cover Steps to decide between a contrib, patched or custom module. Basics of writing/contributing a patch. Basics of writing/contributing a module.

Michael Miles From: Boston, MA Work: Genuine ..a.k.a Planet Hoth (@WeAreGenuine) Exp: Working with Drupal since 2008. Recently named an Acquia M.V.P Twitter: @mikemiles86 Drupal.org: mikemiles86 All the Places: mikemiles86 mike­miles.com

R.E.A.D Research what exists. Evaluate the options. Analyze the gap. Determine amount of change.

Research What Exists

Isolate Keywords Read documentation, specs, etc… Pay attention to unique nouns and verbs. Ask questions!

Perform Searches 30k+ Modules available. Favorite search engine “Drupal [keyword]”. Search on Drupal.org

Utilize the Community Use IRC: #drupal, #drupal­support. Use Stack Exchange: drupal.stackexchange.com. Social Networks: G+, Facebook, LinkedIn. Even reddit! reddit.com/r/drupal.

Isolate Keywords. Perform Searches. Utilize Community.

Evaluate the Options

Read the Description What does the module do? What does the module not do? What does the module depend on?

Community Adoption Downloads vs. Installs vs. Age. Activity of issue queue. Issues are good, not bad!

Maintainer Activity Participate in issue queue? Accepting of feedback? Regular commits and/or releases?

Read the description. Check community adoption. Check maintainer activity.

Analyze the Gap

Download and Test the Module Gain a better understanding. Use a sandbox: simplytest.me. What is offered out of the box?

Discover Missing Functionality What does it not do? Missing 80%? Missing 20%? Bigger gap = Bigger effort.

Check for Community Solutions Look at the issue queue. Search “Drupal [module] [functionality]”. Ask questions!

Download and test the module. Discover missing functionality. Check for comunity solutions.

Determine Change

Review the Module Code Does it follow coding standards? Is it extendable? Can you figure out what does what?

Estimate Effort How much code to rewrite? How much code to add? How much time is there?

Extend or Alter Adding functionality? Changing functionality? Changing the modules goal?

Review module code. Estimate effort. Extend or alter?

Examples

Scenario #1

The Requirements WHEN SAVING A FILE ENTITY AND IT IS A JPEG IMAGE THEN THE EXIF META DATA NEEDS TO BE CAPTURED AND MAPPED TO CUSTOM FIELDS AND THESE MAPPINGS NEED TO BE EXPORTABLE USING FEATURES

Research What Exists

Isolate Keywords WHEN SAVING A FILE ENTITY AND IT IS A JPEG IMAGE THEN THE EXIF META DATA NEEDS TO BE CAPTURED AND MAPPED TO CUSTOM FIELDS AND THESE MAPPINGS NEED TO BE EXPORTABLE USING FEATURES

Perform Search We will focus on the keyword “Exif”

Search Google

Utilize the Community

Evaluate the Options Exif custom seems like best fit.

Read the Module Description

Look at Community Adoption

Look at Maintainer Activity

Analyze the Gap

Download and Test the Module

Discover Missing Functionality

Check for Solutions

Determine Change

Review Code

Estimate Effort Add Features integration. Alter primary key for mappings. Time is minimal.

Extend or Alter Adding features support. Not changing what module does. Extending.

Which Path to Choose Use module as is. Patch module. Write own module.

Patch! Module meets 90% of needs. Small gap, small effort. Extends module.

What is a Patch? drupal.org/patch. A structured list of changes to files. Re­appliable to files. Focused on a single change.

Creating a Patch

Clone and branch module git repo.

Make changes to code.

Test your changes.

Generate patch file.

diff —git a/exif_custom.features.inc b/exif_custom.features.inc new file mode 100644 index 0000000..243bbe2 —- /dev/null +++ b/exif_custom.features.inc @@ -0,0 +1,158 @@ +<?php +/** + * @file + * Features file for the exif_custom module. + / + +/* + * Implements hook_features_api(). + */ +function exif_custom_features_api() { + return array( + ‘exif_custom’ => array( + ‘name’ => t(‘EXIF Custom mappings’), + ‘default_hook’ => ‘exif_custom_export_maps’, + ‘feature_source’ => TRUE, + ‘default_file’ => FEATURES_DEFAULTS_INCLUDED, + ‘file’ => drupal_get_path(‘module’, ‘exif_custom’) . ‘/exif_cus + ), + ); +} +…

Submitting a Patch

Create/comment on issue queue.

Attach your patch. Follow patch naming standards [module]­[description]­[issue­number]­[comment­number].patch

Watch for feedback.

Wait for merge. (hopefully)

Giving back to the community

Scenario #2

The Requirements WHEN SITE USES WORKBENCH TO MODERATE CONTENT THEN CAN CREATE MULTIPLE TRANSITIONS BETWEEN STATES AND TRANSITIONS ARE EXPORTABLE USING FEATURES WHEN EDITNG A CONTENT REVISION THEN CAN SCHEDULE A TRANSITION AND CAN SELECT DATE FOR FIRST STATE AND CAN SELECT DATE FOR SECOND STATE

Research What Exists

Isolate Keywords WHEN SITE USES WORKBENCH TO MODERATE CONTENT THEN CAN CREATE MULTIPLE TRANSITIONS BETWEEN STATES AND TRANSITIONS ARE EXPORTABLE USING FEATURES WHEN EDITNG A CONTENT REVISION THEN CAN SCHEDULE A TRANSITION AND CAN SELECT DATE FOR FIRST STATE AND CAN SELECT DATE FOR SECOND STATE

Search for Existing Modules We will focus on the keywords “workbench schedule”

Search Drupal

Evaluate the Options Look at Scheduler Workbench Integration.

Read the Module Description

Look at Community Adoption

Look at Maintainer Activity

Analyze the Gap

Download and Test the Module

Discover Missing Functionality Unable to create different transitions per type. Unable to select per revision. No features support.

Determine Change

Review Code

Estimate Effort Refactor creating schedules & transitions. Decouple transitions from content types. Add Features integration. Will take time.

Extend or Alter Changing how transitions/schedules are created. Changing purpose of module. Altering.

Which path to choose? Use module as is. Patch module. Write own module.

Build a custom module! Too big/complicated to be a patch. Would alter module goals. No other module exists to support use cases.

Writing a Module drupal.org/developing/modules. Follow Drupal coding standards. Make use of hooks and APIs. Test your code!

Contributing a Module Ask yourself: Could others use this? Seriously, is it abstracted enough?

Name module appropriately. Namespace based on dependencies. Be clear, not clever. Should indicate what module does.

Provide a detailed description. Explain what module does and does not do. Outline any dependencies. Help fellow R.E.A.D­ers.

Be a good maintainer. Bugs are badges not bruises. Participate in the issue queue. Update, release and improve.

Let’s review

Remember to R.E.A.D Research what exists. Evaluate the options. Analyze the gap. Determine amount of change. bit.ly/drupalREAD

Sprint Sunday 09:00-17:00 The Nerdery, 300 N Elizabeth St., Suite 500C http://2015.midcamp.org/schedule Learn through contribution Contributors of all skill sets and levels are welcome and encouraged

Feedback https://joind.in/talk/view/13791 Speaker Name: @mikemiles86 #MidCamp

Thank You! #MidCamp R.E.A.D / Michael Miles