To be SOLID or not to be ?

I had interesting discussion during one of my presentations about SOLID principles. Generally the question is “when we should use these principles?”. There are a lot of people that raise this subject. So I decided to share with you my thoughts.

What SOLID principles are? It is bag of rules which help you to write high quality code. So the real question is “when we need high quality code?”.

Once I had lecture with group of students and they knew SOLID principles very well. But I asked them do they use them? The answer was no. I dug further so I asked why is that. They told me that they have a lot of work with enormous number of projects so they are not able to look at quality of their code. Generally I understand that, cause when you are going to learn something totally new for you it’s natural to focus only on “understanding that thing”. But let’s take a look at students at later years of study. They should have time to learn in practice how do their future work very well.

Another time I had meeting with group of professional developers and they not exactly knew SOLID principles very well. There were a lot of misunderstandings about these rules. I didn’t ask them whether they code according to SOLID principles. I knew they do not. They grumbled that they don’t have time to use these rules. One guy said that they are always prototyping something first and during that stage there is not time for “rules”. He also said that after prototyping stage the prototype is always going on production. I was like James Bond’s drink, shook up. ( About “prototype on production methodology” I will write in future post. ) I asked that guy how much time new developer would need to contribute to theirs project. He said one month. And how much time to simply understand the project. He said three months. Three months???

What exactly mean high quality code ? It means:

  • Easy to maintain
  • Easy to extend
  • Easy to understand
  • Easy to deploy
  • Easy to explain

Going back to main question, when we need high quality code? Every time someone else would use our code directly as a programmer or indirectly as a user of our application. So when you write something only to learn new language or framework it’s OK to focus on that. Of course if you have enough time to practice SOLID principles during these it would be better for you. But what about prototypes? It’s very catchy for business owners to publish prototype on production and then try to develop it. It’s huge misunderstanding of what prototype should be. This is why I recommend you to treat prototypes as normal production application and of course you should implement it according to SOLID principles as much as you can. Cause:

It is not the thing to write working code, but to write working code which is easy to understand for someone else.


Here is my GitHub repository with examples of SOLID principles:

Console.WriteLine(“Hello World”);

3… 2… 1… I’m coming out.

Hi there

I’m Michal I live and work in the most beautiful city in Poland called Lodz. Of course there are people who will not agree that Lodz could be called beautiful but “nobody is perfect” 🙂

In 1996 when I was 11 I got my first PC and began karate trening. Since then these two hobbies became my sens of life.

I “hacked” my first computer in Primary School and I was carpeted by school director in 1999. I simply change autoexec.bat file to display fake information that partition C: was formatted. 🙂

Since 2008 I had been working as .NET developer since 2010 I’ve been Team Leader and .NET Architect.

Here I’d like to share with you my thoughts about programming and software architecture. But firstly would you fly by plane which was built as your software? Really?

So stay tuned.