PHPNews

Newcrafts 2019 Day 1

This week I attended and spoke at the Newcrafts conference in Paris. The following is a mix of notes and personal observations I wanted to share, centered around some of the talks I saw there. Romeu Romera: Bourdieu's Social theory and our work in tech I had never attended a talk by Romeu before. I really …

Continue reading »

Written by Matthias Noback - - Aggregated on Friday May 17, 2019


Hand-written service containers

You say "convention over configuration;" I hear "ambient information stuck in someone's head." You say "configuration over hardcoding;" I hear "information in a different language that must be parsed, can be malformed, or not exist." — Paul Snively (@paul_snively) March 2, 2019 Dependency injection is very …

Continue reading »

Written by Matthias Noback - - Aggregated on Monday March 4, 2019


DDD Europe notes - Day 2

Cyrille Martraire: Domain modeling towards First Principles This was a talk from the first day, but it required some more processing before writing about it. Cyrille is one of my favorite speakers. He's fast, funny and brings a lot of interesting topics to the table. So many that it's sometimes hard to keep …

Continue reading »

Written by Matthias Noback - - Aggregated on Friday February 1, 2019


DDD Europe notes - Day 1

Eric Evans: Keynote ("Language in Context") Starting out with the basics (words have meaning within a context; when we make the boundary of this context explicit we end up with a bounded context ), Eric discussed two main topics: the Big Ball of Mud , and bounded contexts in the context (no pun intended) of …

Continue reading »

Written by Matthias Noback - - Aggregated on Thursday January 31, 2019


Principles of Package Design, 2nd edition

All of a sudden it became book-writing season. It began in August when I started revising my second book, "Principles of Package Design". Apress had contacted me about adopting it, and they didn't want to change a lot about it. However, the book was from 2015 and although I had aimed for it to be "timeless", some …

Continue reading »

Written by Matthias Noback - - Aggregated on Monday December 17, 2018


Assertions and assertion libraries

When you're looking at a function (an actual function or a method), you can usually identify several blocks of code in there. There are pre-conditions , there's the function body , and there may be post-conditions . The pre-conditions are there to verify that the function can safely proceed to do its real job . …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday September 18, 2018


Final classes by default, why?

I recently wrote about when to add an interface to a class . After explaining good reasons for adding an interface, I claim that if none of those reasons apply in your situation, you should just use a class and declare it "final". PHP 5 introduces the final keyword, which prevents child classes from overridin…

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday September 11, 2018


Reusing domain code

Last week I wrote about when to add an interface to a class . The article finishes with the claim that classes from the application's domain don't usually need an interface. The reason is that domain code isn't going to be swapped out with something else. This code is the result of careful modelling work that's done …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday September 4, 2018


When to add an interface to a class

I'm currently revising my book "Principles of Package Design" . It covers lots of design principles, like the SOLID principles and the lesser known Package (or Component) Design Principles. When discussing these principles in the book, I regularly encourage the reader to add more interfaces to their classes, to make …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday August 28, 2018


More code comments

Recently I read a comment on Twitter by Nikola Poša: I guess the discussion on my thread is going in the wrong direction because I left out a crucial hashtag: #NoCommentsInCode - avoid comments in code, write descriptive classes, methods, variables. https://t.co/MuHoOFXCvV — Nikola Poša (@nikolaposa) July 13, …

Continue reading »

Written by Matthias Noback - - Aggregated on Monday August 13, 2018


Objects should be constructed in one go

Consider the following rule: When you create an object, it should be complete, consistent and valid in one go. It is derived from the more general principle that it should not be possible for an object to exist in an inconsistent state. I think this is a very important rule, one that will gradually lead …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday July 17, 2018


About fixtures

System and integration tests need database fixtures. These fixtures should be representative and diverse enough to "fake" normal usage of the application, so that the tests using them will catch any issues that might occur once you deploy the application to the production environment. There are many different options …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday July 10, 2018


Blogging every week

A very important "trick" in finding the flow in life is: do what you like most . Of course, you have to do things you don't like (and then you need different life hacks), but when you can do something you like, you'll find that you'll be more successful at it. When it comes to blogging, I find that it helps to …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday July 3, 2018


Testing actual behavior

The downsides of starting with the domain model All the architectural focus on having a clean and infrastructure-free domain model is great. It's awesome to be able to develop your domain model in complete isolation; just a bunch of unit tests helping you design the most beautiful objects. And all the "impure" …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday June 26, 2018


Doctrine ORM and DDD aggregates

I'd like to start this article with a quote from Ross Tuck's article "Persisting Value Objects in Doctrine" . He describes different ways of persisting value objects when using Doctrine ORM. At the end of the page he gives us the following option - the "nuclear" one: [...] Doctrine is great for the vast …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday June 19, 2018