The PHP community
I'm a proud member of the PHP community. Recently I've come to realize though that "the PHP community" is a very complicated thing, and in fact, not even one thing.
I consider it part of my "job" to keep track of what's going on in the community and I consider Twitter to be the proper place to look for news from the community, as well as a great place to check in on the pulse of the community. What are people happy about, what are people looking at, who are they trolling? This is all fascinating to me.
It turns out that what's going on is not always so nice. Neutral or even funny tweets get misinterpreted as having some negative tone. When a tweet touches a sore point, people are likely to get very angry about it.
PHP "drama"
Some of these conversations are marked as "PHP drama". As some have said earlier (even though I don't have a reference for it), this doesn't do justice to the people involved in the discussion. If something is important to you and someone else downplays your concerns, then that's not really fair.
Recently my inner drama queen (or actually: drama king) awoke when I saw a conversation going on about firing events. The initial question by Jonathan Reinink was about firing events in a controller. Then Yitzchok Willroth said "Controllers firing events?!". I got what that meant, since he was probably referring to a more domain-oriented approach where indeed you're not supposed to create/fire/dispatch events inside a controller. Finally, Jeffrey Way responded:
@stauffermatt @coderabbi @reinink @taylorotwell As we all know, the world will literally blow up, if you fire an event from your controller.
— Jeffrey Way (@jeffrey_way) June 12, 2015
Ready? Fight!
When I read this, I was so much tempted to cook up a spicy response... But instead of letting the anger win and getting myself tangled up into this conversation, I started analyzing what was actually going on:
- I got mad because what Jeffrey said was such a bad argument that he couldn't be serious about it. Surely, every good advice or initiative can be counter-attacked by a response like this.
- Then I thought, he probably isn't serious about this anyway, right? It has to be a joke. Hard to decide though, because I don't actually know Jeffrey in person.
- If he is serious, or even somewhat or remotely serious about this, something else must be going on right? I remember some Laravel people saying things like "let them fight over Active record versus Data mapper while we ship valuable software". Is this comment somehow related?
Discussing matters of faith
Looking at myself, thinking these things, I was suddenly reminded of the way that people tend to deal with "wrongness" in discussions about matters of faith. Being raised as a member of the protestant church I was baptised as a child and when I was 20 I did my confessions, explaining publicly what I believed. Then something curious happened: within the same year, I completely lost my faith. I said goodbye to everything I had believed about life, the universe and everything, and started to completely rebuild that.
This obviously came as a big surprise to my parents, who are both theologians. We are not our biggest enemies today, but it's impossible to talk about certain things. In the past we did try to convince each other (I guess we all wanted to agree on the what and why of the world). This never worked, because from the time I was no longer a practising Christian, it seemed that we lived in different worlds. We even appeared to have completely different rules about thinking itself. When one of us brought in some argument, it sounded to the other person like:
- It was such a bad argument.
- He can't be serious about this.
Finally, I came to the conclusion that indeed, with a different mindset, my parents - of course - couldn't agree with me. What I was saying must have sounded really stupid from their perspective on the world.
Compared to technical discussions
Do you see certain similarities with the discussion about firing events in controllers? To me it's very clear that something like this is going on there as well. Maybe not even in this particular discussion, as well as in many, many other discussions which you read on Twitter.
The way our community is divided often looks like a subdivision based on what people believe. There are Symfonians, Artisans, Drupalistas, etc. There's people who believe that we should all do TDD and there's people who believe that's downright stupid. Some like DDD, some think it's likely to make your application over-engineered. Some do PHP "the right way", some don't.
Having these compartments in our community causes several things:
- We tend to gather followers and followees who reinforce the way we think about programming.
- We tend to fight everything that and everyone who doesn't fit within that way of thinking.
- We tend to blindly follow "thought leaders" who speak the loudest and the most often about the things we find important.
This, again, is not very much unlike what happens within and between subdivisions of a real-world community. A lot of blind following, fighting as well as reinstating previous beliefs.
Conclusion
From this comparison, I draw several conclusions:
- It's perfectly fine to gather people around you who think alike, are interested in the same kinds of things. We all do this, it provides some safety and sanity in a crazy and chaotic world. Most groups within the PHP community are no longer fully compartmentalized anyway.
- Though starting a fight is always tempting, it doesn't lead to converting someone to your opinion. It's not okay to fight with everyone who doesn't agree with you or your group. It's particularly not okay to fight with someone who seems to have a completely different mindset. Even though they sound stupid to you, they may have a set of experiences that's entirely different from yours. And, you know, they can live a successful life as well, believing those "stupid" things, so you might even learn something useful from them.
- Just because a well-known person from the community (guru, hero) says "Don't be afraid to use active record, I'm making big bucks with it!", or "Don't use facades, because, uhm, there be dragons!", doesn't mean you need to follow that advice or blindly parroting them. I don't think any person should be called "thought leader". It sounds to me like blind worshipping. You should never let your thoughts be led by anyone else. You can keep yourself informed on the matter, discuss alternatives with people, but never let someone win the argument just because they are the "leader". Or, as Taylor Otwell puts it:
Important to remember: the “PHP Community” is not the same 25-30 people that speak at most PHP conferences. It’s a big world.
— Taylor Otwell (@taylorotwell) June 12, 2015
What about firing events in controllers?
The unanswered question remains: is it okay to fire events in controllers? With my own (current) mindset, habits, experiences, goals, discipline, etc. I'd say: no. And no, the world won't explode, but I don't think we're better of with events being dispatched in a (web) controller. That may never be an excuse to do the other, "right" thing. And if someone on my team is doing it anyway, I'll ask them to find a better solution for it.
What's absolutely crucial to note is that this is my personal opinion. Even though I know that many people share this opinion with me (people who follow me and whom I follow), I know there are different ways of looking at things as well. I don't want to fight over these issues at all. I just want to set the example that I think is worth setting.
I think software development requires an enormous amount of discipline, which we, being humans, don't always have. Because we "fall back" on suboptimal behavior all day, I think that teachers (bloggers, speakers, etc.) always have to aim quite high, to the point where, yes, some will think that we're overdoing things. That way, we can gradually improve the state of (PHP) software.
I encourage you from time to time and always in a respectful manner, to question my logic. If you're unconvinced a particular plan of action I've decided is the wisest, tell me so. But allow me to convince you. And I promise you right here and now, no subject will ever be taboo. Except, of course, the subject that was just under discussion.
— O-Ren-Ishii, Kill Bill, Vol. I
Just kidding of course ;)
Obviously, you should only fire the event if it keeps delivering bad work, even after it has been warned about this. :-P
FosUserBundle, the most popular bundle in Symfony world, fires events in controllers just fine.
I don't think "it depends" is a helpful response. It's equally unhelpful as the context-less 140 character "thought".
What if we explained _why_ and included the reasons *and* the tradeoffs we are making (or the ones we know about)? I predict there are good reasons (and maybe bad history! ha) why firing events in controllers is rejected by the author. But if you don't expand, if you don't give a lot of "why"s, I'll never grow as a result of being part of the PHP Community... WE will never get better!
If you just want to just spout an opinion, do it out loud so that it then simply disappears. Part of being in a Community is being mindful of one's impact on the Community! If that's too much burden, perhaps one needs to rethink being (involved) in the Community?
</rant>
Thanks for this article, we definitely need more of those: development isn't just about technical stuff, it's also about human interactions.
Let's try to be more curious about everyone's else opinion :)
Every one have an opinion, and it changes over time.
It is the opinion of him at the time, and with more and more experience they may change their mindset.
I think this is probably one of the worst faces about 150 characters limit on Twitter, context is quite more important than we think in terms of technical advices. By the way thank you for dedicating the time to write down this words Noback =D
technically, you can fire an event from any place in your code. what is the right place, then? it depends heavily on the nature and the size of your project and the guidelines you and your peers have established.
what's clearly better for your project may be overkill for mine, so why should i do it in your way when it clearly is easier and simpler with mine?
In a symfony project, where events should be dispatched ? I was pretty sure the controller was the place to dispatch events.
I noted this on Twitter, but, for everyone else...
My comment was very much a joke, which stemmed from my annoyance with the constant dogma in the PHP community in the last few years. So much talk about various coding techniques being dangerous. "I wouldn't recommend that; it's dangerous." Huh? Says who?
What these arguments almost never take into account is context. Many of the famous tech Bibles were written to accommodate very, very large applications - banks and such. But when this advice gets subscribed (virtually mandated) to every single application (even those with, say, 10k lines of code, total), is it any wonder why we end up with massively over-engineered codebases, that go against all common sense? You shouldn't need to be a rocket scientist to figure out how all these pieces fit together.
I *think*... it's all due to this same sort of dogma: "Firing an event from your controller is bad." Or "ActiveRecord is an anti-pattern." Shouldn't we instead be saying, "Well it depends"?
Thanks for the good article. I agree with all this, however I still think there is value in "trusting" the experience of others and looking up to other people. We (unfortunately) don't have the time to learn everything from scratch every time. As always, we need to follow advices and "rules" to learn, until a point where we see the shortcomings and try to break to rules and go beyond.
The big thing is to take context into account. Your question about events in controllers was in a very specific context (a DDD project for a starter), take the same question in a quick and dirty project and of course the answer will be different. I see that happen a lot with dependency injection, it's very easy to start flamewars. For example I'm not afraid to say: using the service locator "anti-pattern" is sometimes fine (e.g. small, quick and dirty Silex project).
Dealing with absolutes is definitely wrong and I think that's the enemy here. You weren't asking for an absolute answer, you were looking for an answer/advices in the context of DDD, and answers outside of that context felt out of place. Of course (and that's one of your point I think), challenging some root assumptions is good and we need to do that regularly. But not every second, else we never move forward. You don't need someone to blindly challenge DDD with "OMG over-engineering" every time it is mentioned.
+1 for "dealing with absolutes is definitely wrong" 😎
I didn't personally see anything on Twitter which signaled that Jonathan's question was in the context of a DDD starter project.
http://d.pr/i/125b6
Mmh yes you are right! It wasn't obvious (except for those who follow Matthias & co on Twitter), it's sure that Twitter doesn't help with this because of 140 chars and because discussions are public and not categorized :)
I agree with this completely. The only "true" answer to any of these kinds of "right" or "wrong" way type questions is "it depends". As you say, context.
Also, as far as following the opinions of "thought leaders", I consider it a convenient shortcut when it comes to learning new things. These people generally earn the respect of others over time by consistently offering valid opinions and good advice. But a good "thought leader" also considers the opinions of others, and never shies away from having their views challenged.
Good read and you're right about the "drama" as well. It can be very hard to separate truth from beliefs, specially in a field where no one "right" way exists, because each circumstance requires something different from us.
As organiser of a lot of community events IRL, I can attest to the many discussions going on about what is or isn't the "right" way of doing things. Luckily, people seem to be much more civil in real live than on Twitter. Not being limited by 140 characters and being able to communicate non-verbally also goes a long way.
That being said: there might be merit to firing events in controllers, as long as they're not domain-specific events. But again, this topic specifically depends on more than just being right or wrong. There is more to it, like specific requirements, environments, etc.
Thanks for sharing, Pascal! Spot on...