Coder Social home page Coder Social logo

solid-samples's Introduction

SOLID - .NET Samples

Simple .NET C# project to show SOLID implemented. The projects show a simple folder with a Problem and the Solution

SRP - Single Reponsability Principle

The Problem is a single class that encapsulates every action surrouding the Client. The model, the data validation, BD connection and e-mail action.

The Solution is to break into multiple classes, each one with a clear responsability on what it should take care of.

OCP - Open-Closed Principle

The Problem is a class that encapsulates the CarRent by type. Every new type added in the future can break the current behavior and bring up problems with unit testing.

The Solution is to create an Abstract class with base implementation on car rental. Each rental type comes later, without mixing the code with the implemented ones.

LSP - Liskov Substitution Principle

The Problem is to show that even though in real life, a Square is a type of Rectangle, this can bring problems to the OO world.

The Solution is to split the Square and Rectangle classes - in this case, sharing an interface to caculate the area. Each class taking care of the specifics behavior.

ISP - Interface Segregation Principle

The Problem is a inteface file with multiple responsabilities. This causes troubles in the enrollment process since Product doesn't have e-mail and phone number to receive SMS.

The Solution is to segregate the interface, with clear definition for each one.

DIP - Dependency Inversion Principle

The Problem show the SRP solution with coupled classes. This makes it hard to test and maintain.

The Solution is to create clear interfaces that are only responsible for each class. This decouples the behavior and the ClientService doesn't need to instantiate the ClientRepository nor EmailHelper directly. The cotainer needs to handle this part.

solid-samples's People

Contributors

yzraeu avatar

Stargazers

Rafael Barrelo avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.