26/02/2019 - PHP
The aim of this post is not to write a piece of code. Instead, it will stay here as a reminder note for all of us. First of all, let us remember how Martin Fowler explains Strangler Pattern and focus on what he says at the end.
"There's another important idea here - when designing a new application you should design it in such a way as to make it easier for it to be strangled in the future. Let's face it, all we are doing is writing tomorrow's legacy software today. By making it easy to be strangled in the future, you are enabling the graceful fading away of today's work."
The simplest example I'll use is from a Symfony application. If you stick all your endpoints in a single Controller (e.g.
UserController) and the relevant logic into a single Service class (e.g.
UserService) then it will be very hard to apply Strangler Pattern in future. If you, at least, kept the logic in different service classes then your future work would be easier. If you didn't, you could easily end up with a service that creates, updates, deletes and fetches user(s) which can also be called a God Object. This is something you definitely don't want.