Mathias Verraes
PHPUnit provides some great features to create mock objects. The idea is that when you are testing code that depends on another class, you provide the object with a mock instance of that class, instead of a real object. That way, you are making sure that your test will only fail if the system under test is broken, and not if one of it’s dependencies is broken. You could simply write a mock class and instantiate it, but PHPUnit can generate them for you.
Mathias Verraes
Doctrine2 does such a nice job abstracting everything related to the database, that you might be tempted to do everything else in your controllers. Say we have a Bug entity
Mathias Verraes
In PHP, when a property or method is marked private, it can only be accessed from within that class. That includes other instances of the same class. This may seem counter-intuitive at first, because we are used to dealing with instances of classes. The visibility operator however works not on object-level, but on class level.
Mathias Verraes
A couple of weeks ago, I switched from Subversion to Git for a couple of smaller projects. Below are some of my findings.
Mathias Verraes
Whenever working with values in object oriented programming, it’s often a good idea to wrap them in a ValueObject. Money is a perfect candidate for a ValueObject
Mathias Verraes
Code doesn’t have to be beautiful. Some of the most successful projects have the ugliest code. Marketing, features, vendor lock-in, shiny GUI’s and all kinds of real or imagined qualities are what make or break a software product. Of all the factors that’ll make you reach your audience, beautiful code dangles somewhere at the bottom. The business value of beautiful code is near zero. CEO’s, managers, customers, and users, they don’t give a shit about the code. So neither should we. Just keep pumping out those LOC’s.
Mathias Verraes
Customers usually have never been forced to really think about their domain in a structured way – let alone explain it in detail to a developer, who doesn’t know anything about that domain. Often the customer doesn’t have a set of clear definitions for the concepts his business uses daily, or has multiple terms for the same concepts.
Mathias Verraes
Closures are a great way to do all kinds of neat tricks in PHP, and they’re particularly useful for Lazy Loading. I’m currently involved in a +200k SLoC legacy project, and the challenge is moving it to a Domain Driven implementation (while improving the performance), with the ultimate goal of making it more testable.
Mathias Verraes
In a discussion about keeping developers motivated, someone said
Mathias Verraes
All code bases I ever read or worked with, share a similar folder structure
Mathias Verraes
Mathias Verraes
I’m a big fan of Value Objects, as they are very helpful in encapsulating behavior, and communicating intent. In fact, as a friend remarked, Value Objects are the heart and soul of Object Oriented Programming. Discussing the uses of Value Objects is not what I want to talk about here though.
Mathias Verraes
CRUD is, as Greg Young calls it, our industry’s Grand Failure. We have deluded our users, and ourselves, that applications are nothing more than a thin layer around our database. We present the user with grids and edit forms, and ask them to fill in fields, that we map more or less directly to our relational tables. We use terms like “data model”.
Mathias Verraes
I usually tell people to stay away from the Symfony2 Form component, or forms libraries in general. The problem is that all these libraries are designed in a very CRUD mindset. You’ve done all the work to keep your models, views, and controllers nicely separated, and then this component comes along and violates every boundary.
Mathias Verraes
Data Mappers (like Doctrine2) help us a lot to persist data. Yet many projects are still struggling with tough questions
Mathias Verraes
Update 2020-01-22 I wrote a new version of this.
Mathias Verraes
Jon Jagger regularly posts snippets from books he’s read on his blog. I think this is an excellent habit, that has helped me to discover some very interesting books, so I want to start doing the same.
Mathias Verraes
Mathias Verraes
Event Storming is a technique where you get the developers and the business stakeholders in a room, and visualize the business processes. You do this using stickies with domain events and causality (such as commands), and end with drawing boundaries for aggregates, bounded contexts and subdomains. It’s developed by Alberto Brandolini and is deeply rooted in Domain Driven Design, and CQRS/ES.
Mathias Verraes
What is the opposite of fragile (breaks when confronted with unexpected events)? Changes are people answer with robustness (stays the same under unexpected events). But there’s another way to look at it.
Mathias Verraes
Many teams are not spending enough time on modeling. Often, they’re not particularly good at it, and often, the business considers time spent at the whiteboard “unproductive”. The goal of the Modellathon workshop, was to give people a safe environment to play around with different modeling techniques, without the pressure of producing something of immediate value. For more experienced attendees, it’s an opportunity to exercise their modeling skills on a new and unfamiliar domain.
Mathias Verraes
“Extract Till You Drop” is a live refactoring that I used to do at conferences and as a webinar.
Mathias Verraes
Here are some guidelines to help you live in friendly cohabitation with your fellow rockstar ninja code monkeys. I’ll update them as my ideas about the matter evolve.
Mathias Verraes
When you first learned Object Oriented Programming, somebody probably told you that objects map to things. And that still holds true most of the time. And maybe somebody explained it using the simple heuristic to “look for the nouns”, which can indeed be a great discovery technique. But then somebody probably phrased that as “class names should not have verbs in them”. To me, that rule is severely limiting the possibilities for your models. So here are some cases where I prefer to use verbs.
Mathias Verraes
I’m a big proponent of pre-merge code reviews. From my experience consulting for teams in problematic projects, I can say that (along with daily standup meetings) pre-merge code reviews are one of the most effective and yet fairly easy changes a team can introduce to radically improve the condition of the project. And even if you consider your project to be healthy, there’s always room for improvement.
Mathias Verraes
I got this mail from a listener of the podcast episode on Value Objects I recorded with Konstantin
Mathias Verraes
I hadn’t done any presentations or blog posts about Command/Query Responsibility Segregation yet, even though I’ve been working with it for more than year (and have been wanting to use it for another year). Volker Dusch invited me to speak at the first ResearchGate Developer Day in Berlin, and offered me the luxury to choose any SE topic I wanted, I just had to do it.
Mathias Verraes
Mathias Verraes
The line is often quoted as an excuse for deliberately ignoring users’ requests for features. It’s usually followed by some mention of the iPhone, Steve Jobs, or Apple in general. And, usually, it’s uttered by people who build a €20 app, not a hardware device or an entire car.
Mathias Verraes
We can’t avoid failure. Systems fail all the time. The deep assumption of failure needs to be engraved in everything we do or build.
Mathias Verraes
Context Mapping, first described by Eric Evans in Domain-Driven Design, is lightweight method of drawing out the relations between systems, and parts of systems. It’s not technical per se. It exposes the politics of the organisations and the teams building the systems. As you start mapping, every edge that connects two systems, defines an upstream, and a downstream point; the latter system being the one that is affected by changes in the former. Or, to put it more graphically
Mathias Verraes
Yesterday, we did a DDD Basics session with the Domain-Driven Design Belgium community. We only covered Strategic DDD, and split up the work amongst the five founders of the group
Mathias Verraes
Context is everywhere. The human brain interprets context immediately, without effort. Try this
Mathias Verraes
Should you always speak and write perfect Oxford English? Most people will agree that this would be impractical, and take a lot of effort. It depends on your conversation partner, or your audience, and, quite importantly, on the expected lifespan of the message. If you are among friends, in the pub, you will most likely speak your local dialect. If you write a text message to your best mate, same. If, on the other hand, you were the King, and you were addressing the nation on a matter of the gravest importance, you’d want it to be in the best English you have at your disposal. If you write a document that is likely to survive you, such as legislature, you’d want to make sure it is still readable in a hundred years. Your local vernacular wouldn’t provide that guarantee.
Mathias Verraes
Traditionally, we create structural models for our applications, and store the state of these models in our databases.
Mathias Verraes
Update 2021-01-25
Mathias Verraes
I make all my classes final by default. I even configured the templates in my IDE prefix new classes with ‘final’. I’ve often explained my reasoning to people. A blog post is in order!
Mathias Verraes
I’ve been dabbling with Functional Programming languages for a while now. Although I can’t say I’m at all proficient, it has affected my programming style. Even if my code is mostly OOP, my whiteboard drawings look more functional. I’m thinking about functions a lot. So it made sense to describe the CQRS-architecture of my system as a set of functions.
Mathias Verraes
See the slides at Speakerdeck
Mathias Verraes
PHP allows only a single constructor per class. That’s rather annoying. We’ll probably never have proper constructor overloading in PHP, but we can at least enjoy some of the benefits. Let’s take a simple Time value object. Which is the best way of instantiating it?
Mathias Verraes
Some of the reactions to my last blog post on Named Constructors in PHP, originate from the notion that static methods are inherently bad and should never be used. This is rather overgeneralized.
Mathias Verraes
Mathias Verraes
You are reading this on an Information Overload Device. Probably one that fits in your bag or even your pocket. You also have a large Information Overload Device in your living room, and there’s a bunch of others spread across your home, your office, and your environment.
Mathias Verraes
Debt is good. Organizations use it all the time to invest. Technical debt can be good. Are you investing wisely? This talk is based on an older blog post of mine.
Mathias Verraes
Inspired by Tim Schraepen’s experience report, I thought I’d list some recent experiences with facilitating Event Storming sessions. You might want to read my older post with notes on facilitating Event Storming sessions, and the huge amount of content Alberto Brandolini has produced on the topic.
Mathias Verraes
Have a look at these two classes
Mathias Verraes
Benjamin Eberlei did a really nice job of explaining refactoring the Feature Envy code smell on his blog. I wrote a comment because I felt the example could be taken one step further. You should read the original post. Below are Benjamin’s code examples (for reference), followed by a repost of my comment.
Mathias Verraes
To reduce the risk of incidents, the FAA imposed the so-called “sterile cockpit” regulation. Most air traffic accidents happen while taking off or landing, or in the vicinity of airports. The rule instructs pilots and cabin crew to refrain from non-essential activities and conversations while the plane is below 10.000 feet.
Mathias Verraes
The talk that I mention is The Framework as an Implementation Detail by Marcello Duarte and Konstantin Kudryashov.
Mathias Verraes
A lot of so-called Object-Oriented Programming1 is in fact nothing more than procedural code wrapped in objects. The funny thing is
Mathias Verraes
My blog post on Small Uncontrolled Experiments landed me an invitation to speak at Agile Cambridge. As the slides are probably not that useful if you haven’t seen the presentation, I advise you to read the blog post instead.
Mathias Verraes
“Software design is just theory.”
Mathias Verraes
Presentation delivered at DrupalCamp Ghent, November 2014
Mathias Verraes
A system’s design is defined by it’s boundaries, and by the way it communicates with other systems. This outward facing design is, all things considered, more important than the internals. It is important whether we are talking about small systems (such as an object) or large systems.
Mathias Verraes
The slides for my talk at Build Stuff in Vilnius. (As often, the slides are not very interesting without the text.)
Mathias Verraes
Let’s have some fun with higher order programming in PHP. I’ll start by showing how to program with Lambdalicious (or λlicious for friends) and introduce the real meat along the way. Don’t worry too much about the dark magic that may appear to power some of the features of Lambdalicious. It’s on GitHub if you’re curious. Just follow along and keep track of all the functions.
Mathias Verraes
“Programming Erlang
Mathias Verraes
Figuring out how much unit tests you need to write, can be tricky, especially if you are new to Test-Driven Development. Some teams strive for 100% code coverage. Some open source projects even announce their test coverage on their GitHub profiles – as if coverage is an indicator of quality. Coverage only measures the lines of code that are executed by the test suite. It doesn’t tell you whether the outcome of the execution is actually tested, let alone how valuable that test is.
Mathias Verraes
Joint post with Konstantin Kudryashov.
Ma
Mathias Verraes
A message is a unit of communication between systems. There are three flavours of messages
Mathias Verraes
Many of the frameworks I’ve worked with, promise to separate responsibilities with MVC. In practice, they end up coupling everything to everything. The forms are coupled to the models, and there’s a grand unified validation layer. This may be convenient at first, but it breaks down for larger systems, and creates headaches when having to support multiple clients. My approach is to clearly separate the validation for the form itself, from the Command validation and the model validation.
Mathias Verraes
Last week, my client’s Chief Product Owner announced to the team they would introduce a set of new requirements using Event Storming, “as Mathias has taught us”. (I’ve visited there regularly for the past half year or so). The session took about ten minutes, and included no brainstorming or collaboration of any kind. The only thing it had in common with Event Storming, was that the PO used colorful stickies.
Mathias Verraes
I was at a client recently, a large insurance and banking company. The organization is over 200 years old. Some of the software is only slightly younger
Mathias Verraes
The video & slides for my keynote at NCrafts 2015 in Paris.
Mathias Verraes
Below is an attempt at illustrating a design/redesign process I went through at a client, who’s started refactoring the core systems their business depends on. Design is the part of software development that is the most messy, the hardest to fit into rules or well-defined processes. In fact, while writing this post, I tweeted
Mathias Verraes
Gated pre-merge code reviews are bad. Always refactor on master. Always do Pair Programming. Don’t use branches. Apply Continuous Integration.
Ma
Mathias Verraes
Video for my CukeUp 2016 lightning talk in London
Mathias Verraes
Mathias Verraes
I submitted proposals to conferences for almost two years before getting accepted. When it finally happened, I found myself in front of a 250 head audience, realising I didn’t actually know how to do proper presentations. I wish I knew then that there are better ways.
Mathias Verraes
Video & slides for my NCrafts talk on software metaphors.
Mathias Verraes
Video of my talk at Agile Testing & BDD eXchange 2016 in London Video of my talk at the DDD London meetup
Ma
Mathias Verraes
Video of my keynote at Neos Conference 2017 in Hamburg
Mathias Verraes
Modelling is more than knowledge management. It’s complexity management. To reduce cognitive load, you split things up, whether at small scale, in code, or in the large, such as Bounded Contexts. But if you choose large boundaries upfront, you risk getting it wrong, and being stuck to them for a long time. Join Mathias in a discussion of better ways of empirically discovering boundaries instead.
Mathias Verraes
Video for my DDD eXchange 2018 keynote in London
Ma
Mathias Verraes
Design the set of Domain Events from a producer so that they can be used to rebuild the producer’s state.
Ma
Mathias Verraes
Replace Free Queries with Domain Queries to decouple from knowledge of the server’s internals.
Ma
Mathias Verraes
Instead of emitting a stream of Domain Events, emit a single Summary.
Ma
Mathias Verraes
Replace cron jobs and scheduled commands, with an agnostic event to indicate the passage of time.
Ma
Mathias Verraes
Mark a small subset of events as public, keep the rest private by default.
Ma
Mathias Verraes
Add redundant information to a Domain Event to reduce complexity in the consumer.
Ma
Mathias Verraes
Explicitly segregate a Bounded Context’s events in visibility layers, with their own language.
Ma
Mathias Verraes
Store the sensitive payload of an event in a separate store to control access and removal.
Ma
Mathias Verraes
Encrypt sensitive information in an event and delete the key.
Ma
Mathias Verraes
My aim is to identify, name, and document patterns, that I’ve used or encountered in my consulting practice. All patterns are anti-patterns when used in the wrong context, so I try to add heuristics, trade-offs, and caveats.
Ma
Mathias Verraes
Listen to a stream of events and produce a new event when a value changes.
Ma
Mathias Verraes
An event’s lifetime lasts until the next event.
Ma
Mathias Verraes
Only keep one event per time unit from a high frequency stream.
Ma
Mathias Verraes
Store the outcome of a decision to guard against rule changes.
Ma
Mathias Verraes
Explicitly conform to the legacy component’s model in an eventsourcing migration.
Ma
Mathias Verraes
Our industry has a tradition of unnatural, compact, lossy naming. This may save on typing, but costs in understandability.
Mathias Verraes
This article was first published in the book Domain-Driven Design
Ma
Mathias Verraes
The versions of this talk are all part overlapping, part different. You should probably pick one at random to watch, and if you want to find out more, skip around a bit in the others.
Ma
Mathias Verraes
I wrote about something that I called the Forgettable Payload pattern. The abstract reads “Store the sensitive payload of an event in a separate store to control access and removal.” Please read the full pattern first. In short, it’s about being able to remove sensitive information from an eventstore, for example upon receiving a deletion request under the GDPR.
Ma
Mathias Verraes
Trying to get people to agree on a single unambiguous definition of a software concept is usually impossible. In the very least, I can point out that such ambiguity exists when it comes to eventsourcing.
Mathias Verraes
“Technical debt” is a metaphor for all software design choices that turn out to be suboptimal, no longer valid, or just plain wrong. These choices incur a cost on future development, and the shortcuts taken today will later slow you down until you “pay back” the debt by fixing the problems. And it’s not only code
Ma
Mathias Verraes
Decision-making heuristics are patterns and ideas that can help us find another angle, generate new options, evaluate them, or otherwise address the problem. They don’t guarantee a good answer, they only give you some possible progress towards an answers.
Ma
Mathias Verraes
(This is a small snapshot from a longer conversation I’m having with Rebecca Wirfs-Brock about Bounded Contexts. It’s very incomplete but I’m posting it anybody who get some value from it in its present form.)
Ma
Mathias Verraes
All models are wrong but simple models are more wrong than complex ones. Simple models are more appealing, easier to teach and spread and apply. Because of that, they can bring value faster, and they can cause harm faster. “Everything should be made as simple as possible, but no simpler.” (Einstein) is great advice, but the risk is that we forget the last bit. It’s not a joke, it’s a serious warning against reductionism.
Ma
Mathias Verraes
There’s a common bias in the tech industry, and I imagine everywhere. When there’s a new idea, and some very smart people will say that the new idea X is really just the old idea Y. The idea could be a model for looking at things, a way of doing things, a technology, a pattern. People will make the case that X is nothing but Y in new packaging.
Mathias Verraes
Imagine a wholesaler of parts for agricultural machines. They’ve built a B2B webshop that resellers and machine servicing companies use to order. In their Ubiquitous Language, an Order represents this automated process. It enables customers to pick products, apply the right discounts, and push it to Shipment.
Mathias Verraes
“The transition to a really deep model is a profound shift in your thinking and demands a major change to the design.” — Domain-Driven Design, Eric Evans
Mathias Verraes
Domain-Driven Design is a software design discipline centred on the principles that
Ma
Mathias Verraes
I had a conversation with Ryan Shriver of Singlestone Consulting — well, mostly a monologue, I didn’t warn Ryan that he should interrupt me more
Mathias Verraes
One of us (Mathias) consulted for a client that acted as a broker for paying copyright holders for the use of their content. To do this, they figured out who the copyright holders of a work were. Then they tracked usage claims, calculated the amounts owed, collected the money, and made the payments. Understanding who owned what was one of the trickier parts of their business.
Ma
Mathias Verraes
In this talk, I discuss the ideas previously presented in the articles “Design and Reality” and “Models and Metaphors”
Ma
Mathias Verraes
When we make decisions, we often do not explore options that have a risk of loss, even if that loss is balanced out by potential gains. I joined João Rosa’s “Software Crafts” podcast to talk about 3 heuristics that help you overcome that bias.
Ma
Mathias Verraes
Within a Domain Event, use separate timestamps to distinguish when the event occurred and when it was captured.
Ma
Mathias Verraes
I joined Alex Bolboacă on his podcast ‘Think. Design. Work Smart.’ We discussed DDD, the value of models, misconceptions about DDD (it’s not a Big Design Upfront method!) and more.
Ma
Mathias Verraes
The Inverse Conway Manoeuvre is an organisational engineering device. It tells us to change our team and organisational structure to achieve the system design we want. More and more organisations reorganise based on this idea, and yet they don’t end up with the system they’d like. What are we missing?
Mathias Verraes
Contents
Ma
Mathias Verraes
Rebecca Wirfs-Brock and I published a book last year called “Design & Reality” with essays on software design. It’s available on Leanpub.
Mathias Verraes
Here’s the video of Rebecca Wirfs-Brock & my keynote at Domain-Driven Design Europe 2022, where we talk about the ideas presented in our essay “Critically Engaging with Models”, also available as an e-book on Leanpub.
Ma
Mathias Verraes
Software Captains is a organisation that helps startup CTOs through coaching, advice, and networking. In the interview, the founder Tom Klaassen and I discuss software design. We talk about challenges CTOs face, such making technical debt visible for non-technical colleagues, about how software quality is contextual, but still very important even for early stage startups.
Mathias Verraes
The new DDD Australia user group just had its first meetup, and I was invited to speak. A major bottleneck for fast high quality software development is that people in the organisation don’t understand their systems and domains well enough. So I did a (mostly improvised) session on using Bounded Contexts to manage meaning and understandability.
Mathias Verraes
I was at Full Stack Europe 2022 in Antwerp, and one of the speakers had to cancel. So I offered to do an improvised talk on Parsers Combinators. (My Covid Lockdown hobby was creating an open source library to help you build parsers, so I have some experience.)
Ma
Mathias Verraes
On the DevJourney podcast, Tim Bourguignon asked me to talk about my career.
Ma
Mathias Verraes
Below are the common patterns I use when writing tests for an EventSourced application. I’m documenting them here because I mention them regularly and I needed a place to point people to. I believe I talk about them in some of my Temporal Modelling talks.
Mathias Verraes
Design choices carry along the worldviews of the designer. This often is not apparent, especially when design ideas are for obvious technical improvements. Let’s look into a design challenge faced by a fictional Maker Lab.
Mathias Verraes
There’s a moment where it’s too soon to invest in a radical new software design for your system. And then you reach a moment where it’s too late, too expensive to change it. Is there a sweet spot in between, a point where pivoting the software design is the right choice, at the right time?
Ma
Mathias Verraes
Here’s roughly how I fixed bugs early on in my career
Ma
Mathias Verraes
I’ve reviewed conference talk submissions for 10 years, for Domain-Driven Design Europe and other events. Here are my assorted tips for writing your own submissions.
Ma
Mathias Verraes
I wrote this joke exactly 10 years ago
Ma
Mathias Verraes
Here’s a myth that won’t die