As a developer I always pretend that I know about principles, Rules, methods, KISS and YAGNI! But in some cases if you consider my codes you will find out that they are just some best bunch of code for giving an example as introduction dirty code for teaching YAGNI principle!

YAGNI is a principle of extreme programming that says "Never add functionality until deemed necessary". what I mostly make mistake is adding some extra functionality earlier and most of the time they never been used.

 

   &nbs...

Maybe you have heard this for times: "Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification."

it should be possible to extend the existing code with new functionality without any modification and without adding duplicate code or duplicate functionality. Take a look at this piece of code: 

  1.  public class ElementerySchool
  2.     {
  3.         public double Norm { get; set; }
  4.         public int Age ...

As you know, Dependency Inversion Principle is the last principle of SOLID. I talked about SOLID principle and fundamental in my previous post that was about SRP. Now I'm gonna to consider the dependency inversion of SOLID. Based on definition "High level modules should not depend upon low level module, both should be depend upon abstraction". Or in other definition "abstraction should not depend upon details, details should depend upon abstraction...

SOLID stands for five basic principles of Object Oriented programming to create a system that is easy to maintainable and  extensible. The principles of SOLID are guidelines to create refactored and clean code understandable by other developers. Here are the five principles of OOP:

 

Single responsibility principle

Open-Close Principle

Liskov Substitution Principl...

"no client should be forced to depend on methods it does not use." Interface segregation is a Simple but useful patterns of SOLID principle , in other words interface segregation is just about splitting an interface to several interfaces to make it simple working with classes those are going to implement the members.

Example

Suppose this interface :

  1.     public interface IAccountService
  2.     {
  3.         void CreateBankAccount();
  4.         vo...

Liskov substitution principle (LSP) is a simple pattern in object oriented programming ,notice about definition If A is a subtype of B, then object of B could be replaced with object of A, in other definition subclass  can behave like base class. maybe you are using it for years, take a look at  the example:

  1.     public class BaseClass
  2.     {
  3.         public string ProductName { get; set; }
  4.         public Continue