What I've learned at SOLIDay 2015

By Filip Božanović -

This was supposed to be a quick recap of my experiences at SOLIDay Serbia (May 30th, 2015), but I’ve opted for a lengthier exposition because there was so much going on and a short post just wouldn’t do the event justice.


Designing a model architecture - Shawn McCool

After a short foray into what constitutes most of today's MVC implementations, Shawn highlighted that a SOLID separation of concerns might entail maintaining a presentation -> service -> domain divide. Some nifty solutions were presented in the form of the command and publish/subscribe pattern while some issues in maintaining the separation lie with use cases on the boundary of service and domain. Touching on many topics in the DDD problem space was unavoidable, with some commentary on Dependency injection. Overall, it was clear that a lot of effort was put into the presentation and I’m looking forward to future talks by this author.

Getting started with Dependency injection - Rob Allen

I'll start with the takeaway - Dependency injection is simple and necessary. Rob (a Zend Framework contributor, among other things) analyzes the DI pattern starting with an alternative - registry (used in past versions of ZF), locators and DI (in the setter, getter, constructor and interface variants). Rob expertly discusses the pros and cons of each approach, and I’ve certainly learned a lot.

Identity - Matthias Verraes

"There are more unique ids than atoms in the universe." (paraphrasing, don’t kill me)

While the speaker’s domain knowledge is indisputable, the presentation felt a little bit rushed, perhaps even under-prepared. The subject topic was rather fuzzy, considering the latter part of the talk delved into value objects more than ‘identity’ per se. However, there were some good parts worth remembering and I enjoyed his approach to deconstructing the presented use case.

Sylius under the hood - Paweł Jędrzejewski

For me, Paweł was a breath of fresh air. After a loving introduction to the audience and some banter, he discussed the pros and cons of working on an open-source project versus single company projects (open source inherently presents a palette of use case vectors). He briefly introduced us to Scrutinizer - a tool for continuous inspection, before a quick glance at the Sylius eCommerce solution, inspired by Symfony. Paweł also discussed some of the finer design choices in Sylius, such as ubiquitous binding to interfaces, avoiding the new keyword (delegation to factories) and other SOLID practices in PHP.

Extremely defensive PHP - Marco Pivetta

Due to inopportune lunch/coffee breaks and a general fatigue sweeping over the audience, I had a feeling it was going downhill from here. Boy, was I wrong. To reanimate the slumbering audience, he started off by insulting every man, woman and child in the room (okay, there weren’t any children), asserting that ‘haters gonna hate’ (paraphrase) before moving on to some pointers on improving your code. While some may argue the professionalism of this approach, I found it invigorating and gave an inaudible ‘well played’.

The recommendations he gave included the famous book Code Complete 2, and, perhaps surprisingly, Effective Java, however, it isn’t a stretch considering modern PHP, especially on the enterprisey side, is often compared to Java.

Next, Marco quoted Theodore Sturgeon: “Ninety percent of everything is crap.” In order to avoid producing crap, and as the name of the talk implies, the remaining segments (and I’m surprised at just how much material he managed to jam into the time slot) dealt with object calisthenics - a practice which can be likened to avoiding either: a) exposing your foot, b) having a loaded gun pointed at it, c) pulling the trigger, all from the standpoint of good SOLID design.

Some of his points could be considered controversial, but Marco did an excellent job presenting the underlying rationale. For instance, he advocated avoiding logic switch parameters, maintaining immutable state (a trait common in functional programming), avoiding setters and maintaining the constructor as the single point of injection, using public methods sparingly, avoiding mixing return types, avoiding interface inheritance if it does not add any meaning. In order to further nail down immutable state, one should either ensure deep cloning or disable it completely. The same goes for serialization, which depends on whether the every dependency in the object life-cycle is known. The final segment of his talk gave some tips on testing.

I couldn’t help but draw an analogy between this talk and Douglas Crockford’s book Javascript the Good Parts, which presents a small subset of the language that’s ‘safe’ to use. All in all, I found the presentation extremely enjoyable, so much so that I just had to pester Marco for a sticker.

The Seven Deadly Sins of Object-Oriented Development - Brandon Savage

In an effort to keep this post reasonably short, I’ll try not to go into too much detail, but here’s Brandon’s list:

1. Tight coupling - usually means too many dependencies. Remedied by the mediator pattern, service location, factories instead or reducing the complexity. Exposing internal methods is another problem.

2. Extending your interfaces - declare your base classes abstract, kids! Also, type hint object types. Unsurprisingly, this was a leitmotif of the conference. When in doubt, make zillions of interfaces.

3. One class

4. Overbearing interfaces - keep interfaces simple, avoid unused method implementations.

5. Failure to adhere to the Object-Oriented paradigm. Globals are evil, as are any global-like constructs you can think of. Also, use wrappers for native procedural libraries and while you’re at it, be careful not to reinvent the wheel.

6. Knowing too much - unless you want your classes to go sleep with the fishies, they should know as little as possible.

7. Over-abstraction - don't write code for the sake of writing code, solve problems! Write the least amount of code possible. It goes without saying that Chris Hartjes will look at you angrily if you do not test your code.

This talk was another favorite of mine, and Brandon absolutely nailed it.

All in all...

... the conference was amazing and I absolutely loved the talks. A big thanks to the organizers, PHPSerbia, who did a fairly good job organizing an event of this scale.

See you next year!


This site uses cookies. Some of these cookies are essential, while others help us improve your experience by providing insights into how the site is being used. For more detailed information on the cookies we use, please check our Privacy Policy.