The main objective of doing the port is to learn the concepts of Drupal 8. Make this module available for Drupal 8. And also, open sourcing - giving back to the community.
I got the chance to do things hands-on which I only knew in theory.
Being more of a hands-on guy, I am not satisfied by just reading the theory, I get an itch to do that practically as well.
Object Oriented Programming in PHP
I knew the basics of OOP in PHP. But while I was working, I frequently referred the code written in the Commerce core, and it heavily inspired me. The core uses the strategy pattern. And it felt very clean to me - You use an
interface to define the behavior of a
class. And you can utilize the benefits of type hinting using the
Dependency Injection in PHP
I read about the Dependency Injection concept but never got the chance to implement it. While porting the module, I used services (also see Symfony services) to make commonly used methods available across the module, and they will be loaded at the time of object instantiation.
I am a fan of loosely coupled architecture. Dependency Injection helps you to make your code more loosely coupled and clean. It helps you maintain the state of the execution, and is more OOP aligned.
Acquia’s article Dependency Injection mentions the benefits of using services and loading them via Dependency Injection.
Test Driven Development (TDD)
I have so much read about TDD, and this time I got the chance to follow the process.
At the initial stages of the porting, since because Drupal 8 and its test framework was not very much clear to me, thus it wasn’t possible to follow the TDD process.
Once the base of the module (with tests) was complete, I started following TDD. I followed the TDD cycle while adding the features/integrations in the module.
I now feel more confident following the TDD process
Although there are still many bugs in the module for a stable release, still I learned a lot.