/DesignPatterns-2

In this repository, i will explain design patterns and which problems can be solved via these patterns.I especially try to use real world scenario.

Primary LanguageC#

Design Patterns-2

Total patterns will implement on BaseProject.Moreover in BaseProject,was created with carefully in terms of Inversion Of Control & Dependency Inversion Principle.

1-Strategy Design Pattern

Main Goal Of Strategy Design Pattern : This design pattern provides us to change object's behaviour on the run time.

In this scenario,we have two database for using and we give chance to user can switch which database want.I use two database.One of them is SqlServer,another is MongoDb. By using Strategy Design Pattern, u don't need to change database on compile time,u can easily change database on run time with dinamically.

Requirements :

  • MongoDbAtlas
  • SqlServer
  • EntityFramework Core
  • EntityFramework Core Identity
  • EntityFramework Core SqlServer
  • EntityFramework Core Tools

Strategy Design Pattern

2-ChainofResponsibility Design Pattern

Main Goal Of ChainofResponsibility Design Pattern : This design pattern provides us to bind our all process moreover seperate this process to step by step.With this way , when u want to add new part or new behaviour to your application, you can easily add a new chain in addition to that gives a chance to modify your step.

In this scenario, we have 3 steps. This means our application has 3 chains:

  • Excell Process
  • Zip Process
  • E-mail Process

Requirements :

  • ClosedXML
  • SqlServer
  • EntityFramework Core
  • EntityFramework Core Identity
  • EntityFramework Core SqlServer
  • EntityFramework Core Tools

ChainofResponsibility Design Pattern

3-Command Design Pattern

Main Goal Of Command Design Pattern : This design pattern provides us to capsulate our all methods.When u want to modify,u can easily reach your Command invoker in addition to that it gives a chance to losely coupled classes.

In this scenario, we have 3 steps. This means our application has 3 commands:

  • Excell Process
  • Pdf Process
  • Excell&Pdf + Zip Process

Requirements :

  • DinktoPDF
  • ClosedXML
  • SqlServer
  • EntityFramework Core
  • EntityFramework Core Identity
  • EntityFramework Core SqlServer
  • EntityFramework Core Tools

Command Design Pattern

4-Observer Design Pattern

Main Goal Of Observer Design Pattern : This design pattern provides us to observe object from the other objects which is binded with it.Observer DP gives an oppurtunitty losely coupled classes in terms of high level modules to low level modules.Moreover,it provides writing codes shed light from SOLiD Principles.

In this scenario, we have 3 steps. When a new user register our application:

  • Log to Console;
  • Create a Discount to New User;
  • Send E-mail automatically."Wellcome www.default.com site "

Requirements :

  • SqlServer
  • EntityFramework Core
  • EntityFramework Core Identity
  • EntityFramework Core SqlServer
  • EntityFramework Core Tools

Observer Design Pattern

5-Adapter Design Pattern

Main Goal Of Adapter Design Pattern : Adapter Design Pattern is very common in terms of usage;because it is very usefull.Even tough application was deployed with this pattern you may change any interfaceses without touch general structure.Common example for AdapterDp is , electrical socket.When you can not use same input socket , you can add a new one which provide exchange type of your socket to suitable one.

In this scenario, we have 2 steps.Our Application will watermark to our image which we save.

  • Watermark to Image with Manuel code;
  • Watermark to Image with Thirdpart tool;
  • Use Adapter for this process

Requirements :

  • DrawingCommon
  • A Thirdpart Image Resizer
  • EntityFramework Core
  • EntityFramework Core Identity
  • EntityFramework Core SqlServer
  • EntityFramework Core Tools

Adepter Design Pattern