PHPNews

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


Road to dependency injection

Statically fetching dependencies I've worked with several code bases that were littered with calls to Zend_Registry::get() , sfContext::getInstance() , etc. to fetch a dependency when needed . I'm a little afraid to mention façades here, but they also belong in this list. The point of this article is not to bash …

Continue reading »

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


Deliberate coding

I wanted to share an important lesson I learned from my colleague Ramon de la Fuente . I was explaining to him how I made a big effort to preserve some existing behavior, when he said something along the lines of: the people who wrote this code, may or may not have known what they were doing. So don't worry too …

Continue reading »

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


Remote working

Recently I read Ouarzy's review of Jason Fried and David Heinemeier Hansson's "Remote - Office Not Required". I'd read their previous books, "Getting Real" and "Rework". They're all a joy to read. Short chapters, nice little cartoons. Just a lot of fun, and inspiring too. Not many authors make as much of an effort …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday May 1, 2018


Context passing

I'm working on another "multi-tenant" PHP web application project and I noticed an interesting series of events. It felt like a natural progression and by means of a bit of dangerous induction , I'm posing the hypothesis that this is how things are just bound to happen in such projects. In the beginning we start …

Continue reading »

Written by Matthias Noback - - Aggregated on Tuesday April 24, 2018


Combing legacy code string by string

I find it very curious that legacy (PHP) code often has the following characteristics: Classes with the name of a central domain concept have grown too large. Methods in these classes have become very generic. Classes grow too large I think the following happened: The original developers tried to …

Continue reading »

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


Exceptions and talking back to the user

Exceptions - for exceptional situations? From the Domain-Driven Design movement we've learned to go somewhat back to the roots of object-oriented design. Designing domain objects is all about offering meaningful behavior and insights through a carefully designed API. We know now that domain objects with setters for …

Continue reading »

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


Mocking the network

In this series, we've discussed several topics already. We talked about persistence and time , the filesystem and randomness . The conclusion for all these areas: whenever you want to "mock" these things, you may look for a solution at the level of programming tools used (use database or filesystem abstraction …

Continue reading »

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