Help, I need to refactor, but where should I start ? (SDP to the rescue)

Of course it’s impossible to answer this question in one single post, or even in one single book (the best known book for this is the one from M.Feathers, “Working Effectively with Legacy Code” that you can buy here). In fact it’s impossible to answer this question at all as it will all depend on what is the current status of what you have to refactor and every situation is specific. But still, there are few things that can be said and that can/should be applied when it’s about refactoring. Continue reading “Help, I need to refactor, but where should I start ? (SDP to the rescue)”

Protect yourself from models !

You probably use models in your code every day and so do I. The major problem with a model is that it will surely evolve. It will evolve because the business will require a change or because a new feature will be needed and thus will require the model to change or because the api will have new fields or different informations. The best case is that this evolution will not touch your code, the worst case is that this evolution will destroy your code. But in any case you depend on this model and this is generally bad… Continue reading “Protect yourself from models !”

What is Dependency Inversion ?

Dependency Inversion is a very simple concept : “if a class B depends on a class A, you can revert this dependency by generating a contract that class A must implement”. Thus you became responsible for this contract and you do not depend anymore on anyone because they will have to implement your contract and not you… Continue reading “What is Dependency Inversion ?”

How I discovered Dependency Inversion…

One of the first thing that made me think that architecture mattered was when I discovered what Dependency Inversion was all about.

First I was generally mixing Dependency Inversion and Dependency Injection. For sure you better associate them but they can be used independently if you want. To me Dependency Injection was about : I want to have a class and be able to use it with what I want and I want to be the master of this. It was also the D letter in the acronym SOLID (this is wrong if you don’t know… 🙂 D is for Dependency Inversion). I was even pushing this during interviews and I was fully wrong… Continue reading “How I discovered Dependency Inversion…”