Design Principles & Patterns

/Design Principles & Patterns

Over the years software industry has evolved a lot. We have seen gigantic upgrade in computer hardware and software have evolved and become more and more complex. It is more important now than ever before that software developers write excellent quality code as they are responsible for automating everything from nuclear missiles to air radar systems. It is important that we adapt to the best design principals and patterns that have been developed over the years as they will aid us in writing better software for our customers.

9 09, 2016

Readable, maintainable tests using the builder pattern

By | September 9th, 2016|C#, Design Principles & Patterns, TDD / BDD|0 Comments

One of the most important aspect of TDD is writing unit tests that are more readable and maintainable. Lot of people fail with TDD because when they add more unit tests to the code, they don’t put the effort to make them more readable and maintainable. I have seen cases where adding an extra dependency to a class would mean that the developers needs to modify 100 tests where they were creating an instance of that class. This is a result [...]

16 02, 2015

Liskov Substitution Principle

By | February 16th, 2015|C#, Design Principles & Patterns|2 Comments

In the previous post I discussed the Open Close Principle, today I will talk about Liskov Substitution Principle. Liskov Substitution Principle is the third principle in SOLID principles. Original definition of Liskov Substitution Principle states that Let q(x) be a property provable about objects x of type T. Then q(y) should be provable for objects y of type S, where S is a subtype of T. This definition is not very clear to understand, later Robert C. Martin (Uncle Bob) [...]

16 02, 2015

Open Close Principle

By | February 16th, 2015|C#, Design Principles & Patterns|0 Comments

In the previous article we discussed about the Single Responsibility Principle. Today we are going to discuss about the second SOLID Principle that is the Open Close Principle. Open Close Principle states that Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. In first look it might seem like a contradictory statement, how can a class be closed for modification but at the same time open for extension? To answer this question take a [...]

14 09, 2014

Use Provider Pattern to Make Code More Extensible

By | September 14th, 2014|C#, Design Principles & Patterns|0 Comments

Provider pattern is an extremely useful pattern that allows you to write loosely coupled components in .Net framework that can be injected at run time. The concept of provider model is very simple, yet extremely powerful. We create abstraction for our components and define which concrete implementation we want to use in the configuration file. When the code executes, we can create instance of the concrete component mentioned in the configuration file and use that instance to do work. Using a Provider For Logging Let's [...]

25 04, 2014

Single Responsibility Principle

By | April 25th, 2014|C#, Design Principles & Patterns|1 Comment

In modern day world just knowing how to write code is not enough. If you have ever played chess, you would know that the way grand masters play their game is totally different from the way novice or even intermediate players play. It has been proven scientifically that grand masters are always playing for patterns in a game of chess. When a beginner is faced in a position he just starts thinking of all the possible moves that he can [...]