The anatomy of a library – Tips & Tricks – Library ideas: which problems to tackle



The anatomy of a library – Tips & Tricks – Library ideas: which problems to tackle

0 0


decoupling-drupal-modules

Slides for the "Decoupling Drupal modules into PHP libraries" tak

On Github bojanz / decoupling-drupal-modules

Bojan Zivanovic Commerce Development Lead at Commerce Guys

Commerce Guys

Paris | London | Ann Arbor, MI

Creators of Platform.sh and Drupal Commerce

We're a Drupal powered eCommerce company now headquartered in Paris with offices in London and Ann Arbor. We formed the international company through a small merger in 2010 to create Drupal Commerce and Platform.sh. We're now up to around 60 people, about 25% distributed, delivering a wide variety of projects across North America and Europe.

Our story has always been based around solving the hard parts of eCommerce together; the first time we ever cooperated as an international team, in fact, was to develop a new site for a global brand that was multilingual, multi-currency, and with locale specific payment gateways and product availability. It was hard. Very hard. We still see the ghost of that project wandering around our office. We were still using Ubercart at the time and knew we needed to do better.

So we created Drupal Commerce!

3.5 years since the first release...

And now we start from scratch

Re-evaluating our problem space

Libraries first

Influencing symfony/intl

Territorial groupings

  • California and Nevada
  • European Union
  • Germany and a set of Austrian postal codes (6691, 6991, 6992, 6993)
  • Austria without specific postal codes (6691, 6991, 6992, 6993)

Coming to a SaaS near you

More to come

Why?

  • Re-examine your problem space.
  • Get additional exposure.
  • Validate your implementation
  • Get development/maintenance help.
  • Allow for backports.

The (not so) hidden cost

The anatomy of a library

Data model - The basics

Data model - Traits

Data model - Collections

Data model - Repository

Services

Tips & Tricks

Keep in mind that your library needs to feel native to users of very different systems. For example: Drupal, a dynamic and introspective configuration driven system and Symfony, a static, code driven system. Know what developers from both platforms will expect.

Translatable strings

Pluggable implementations

Know when to stop!

Some problems should be solved one level above, in the implementing application. Do not be afraid of code duplication.

Library ideas: which problems to tackle

Hard problems

Takes a lot of domain knowledge to get right. Others get it wrong.

Boring problems

Takes a long time to get right (corner cases).

Are you saving me time?

Nobody cares about your CartInterface.

Spreading the drop

Migrate. Views. Rendering and caching?

Questions?