We're getting OOP wrong and there's still time to fix it

Click here to watch We're getting OOP wrong and there's still time to fix it.

In Drupal 8, we've tried to break up our procedural codebase into classes, use statics as as a last resort, and abstract the instantiation of these classes with a service container. As we've seen already, this can add a considerably amount of complexity, but we often justify it with the idea that our code is more flexible and unit testable.

The fundamental problem with this approach is that we don't write unit tests. Until very recently with PHPUnit, the only option we had was UnitTestBase which supported using db connections! Lack of real unit testing and a strong desire to make our code DRY to the point of dehydration, has produced tightly coupled components that are difficult to work with and test.

Why is the User class, one of the simplest examples of thing you can model in a class, in the Drupal\user\Plugin\Core\Entity namespace? Our implementation details are so exposed they are in our namespaces!

I would like to see the Drupal community embrace the concept of Models, and start creating classes that encapsulate their business logic in a way that makes them easy to understand and work with.

In this session I will talk about how modeling our classes better and unit testing them will help make Drupal easier to conceptualize and easier to work with in contrib.

Schedule info
Time slot: 
Tuesday, May 21 - 09:00am-10:00am
A 105 - Pantheon
Session Info
Core Conversations
Experience level: 


I'm really interested in this discussion. I think a lot of core contributors have some unease with the current complexity, but aren't sure how to fix it with everything we still need to do. I'm aslo concerned that D8's DX needs to improve for D8 to be really successful.

The presentation was effectively 101 for good OOP practices. Hard to imagine anyone having much to object to any of suggestions.

The real question - why we even have to talk about it this late in D8 dev cycle?

Hate to be pessimistic about it... but if it have not happen so far, what are chances of this happening before end of 2013?

I just watched the video. Bravo. One of the best Drupal presentations I have have ever seen. Thanks for bringing such insight to the D8 codebase.