aemloviji / solid-in-dotnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About the repo

The repo contains code examples written in C# to give understanding about how we can archive each SOLID idea during development.

What is SOLID

Source: Wikipedia

In software engineering, SOLID is a mnemonic acronym for five design principles intended to make object-oriented designs more

  • understandable
  • flexible
  • maintainable

The principles are a subset of many principles promoted by American software engineer and instructor Robert C. Martin, first introduced in his 2000 paper Design Principles and Design Patterns.

The SOLID ideas are

  • The S ingle-responsibility principle: "There should never be more than one reason for a class to change." In other words, every class should have only one responsibility.
  • The O pen-closed principle: "Software entities ... should be open for extension, but closed for modification."
  • The L iskov substitution principle: "Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it."
  • The I nterface segregation principle: "Many client-specific interfaces are better than one general-purpose interface."
  • The D ependency inversion principle: "Depend upon abstractions, not concretions."

The SOLID acronym was introduced later, around 2004, by Michael Feathers.

Techniques for detecting violations of the principle

Single responsibility principle (SRP)

  • Method/Property/Class contains a lot of functionality which belong to different layer. For instance
    • Read data from console
    • make some input validation
    • based on entered input grab data from Datasource
    • write to the log directly wihtout refering any other module/class
    • send metrics directly wihtout refering any other module/class

Interface segregation principle (ISP)

  • Too big interfaces
  • Weak cohesion between components (i.e. Methods, Properties) in interface (smell violation of SRP)
  • Methods wihtout implementation (smell violation of LSP)

About


Languages

Language:C# 100.0%