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:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s