diff --git a/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/BadExample/BadEmployeeProcess.cs b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/BadExample/BadEmployeeProcess.cs new file mode 100644 index 0000000..47be918 --- /dev/null +++ b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/BadExample/BadEmployeeProcess.cs @@ -0,0 +1,47 @@ +using SolidPrinciples.Lab_1_SingleResponsiblePrincible.Model; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_1_SingleResponsiblePrincible.BadExample +{ + public class BadEmployeeProcess + { + public void InsertEmployee(Employee newEmployee) // That is insert of Employee our 1 work on the Theorical example. + { + StringBuilder sb = new StringBuilder(); + try + { + #region 1.Process=>First Job Adding New Worker + sb.Append(newEmployee.Id); + sb.AppendLine(); + sb.Append(newEmployee.FirstName); + sb.AppendLine(); + sb.Append(newEmployee.LastName); + sb.AppendLine(); + sb.Append(newEmployee.HireDate); + File.WriteAllText(@"C:\SolidEmployeeData.txt", sb.ToString()); + #endregion + + + } + catch (Exception ex) + { + #region 2.Process=>When the failure of this first process + sb = new StringBuilder(); + sb.Append("Failure Date:"); + sb.Append(DateTime.Now.ToString()); + sb.AppendLine(); + sb.Append("Failure Message:"); + sb.Append(ex.Message); + File.WriteAllText(@"C:\SolidLog.txt", ToString()); + System.Windows.Forms.MessageBox.Show("Opps..Warning Failured"); + #endregion + + } + } + } +} diff --git a/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/GoodExample/GoodEmployeeProcess.cs b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/GoodExample/GoodEmployeeProcess.cs new file mode 100644 index 0000000..3587cc9 --- /dev/null +++ b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/GoodExample/GoodEmployeeProcess.cs @@ -0,0 +1,50 @@ +using SolidPrinciples.Lab_1_SingleResponsiblePrincible.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_1_SingleResponsiblePrincible.GoodExample +{ + public class GoodEmployeeProcess:GoodLogerProcess + { + GoodEmployeeProcess logger; + public GoodEmployeeProcess() + { + logger = new GoodEmployeeProcess(); + } + + string log; + public bool InsertEmployee(Employee newEmployee) + { + StringBuilder sb = new StringBuilder(); + try + { + sb.Append(newEmployee.Id); + sb.AppendLine(); + sb.Append(newEmployee.FirstName); + sb.AppendLine(); + sb.Append(newEmployee.LastName); + + log = logger.BuildLog(sb.ToString()); + logger.LogFile(@"C:\SolidLog.txt", log); + + log = logger.BuildLog($"Employee insert successfull => {newEmployee.Id}"); + logger.LogFile(@"C:\SolidLog.txt", log); + + return true; + } + catch (Exception ex) + { + + log = logger.BuildLog("Failure Message:" + ex.Message); + logger.LogFile(@"C:\SolidLog.txt", log); + + return false; + + } + } + + } +} diff --git a/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/GoodExample/GoodLogerProcess.cs b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/GoodExample/GoodLogerProcess.cs new file mode 100644 index 0000000..08724b6 --- /dev/null +++ b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/GoodExample/GoodLogerProcess.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_1_SingleResponsiblePrincible.GoodExample +{ + public class GoodLogerProcess + { + public void LogFile(string filePath,string log) + { + File.WriteAllText(filePath, log); + + } + public string BuildLog(string information) + { + StringBuilder sb = new StringBuilder(); + sb.Append("Date:"); + sb.Append(DateTime.Now.ToString()); + sb.AppendLine(); + sb.Append("Information:").Append(information); + return sb.ToString(); + } + } +} diff --git a/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/Model/Employee.cs b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/Model/Employee.cs new file mode 100644 index 0000000..3ea4d7c --- /dev/null +++ b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/Model/Employee.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_1_SingleResponsiblePrincible.Model +{ + public class Employee + { + public int Id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public DateTime HireDate { get; set; } + + } +} diff --git a/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/Theorical.txt b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/Theorical.txt new file mode 100644 index 0000000..cefb6a1 --- /dev/null +++ b/SolidPrinciples/Lab_1_SingleResponsiblePrinciple/Theorical.txt @@ -0,0 +1,15 @@ +Single Responsibility Principle + + This principle support that " One class should have just a one job" and " One class should have just a oneresponsibility."Most of Developer,ın the scenerio that wants to add new property or new behaviour,they provide same class.That is totally wrong approach in terms of SRP.When it is applied these codes becomes long and complex and it effects time management when repair. + + For example, + Registration of new worker; + *New worker notifications, + *Send to notification of new worker to Manager, + + In this situation,we can all of them just a one class.But if we do that,we will face with SRP.Why do we prevent to failure of SRP? + -First of all codes that is writen , may change to spaghetti codes.And it will be problem on the repair time or when we want to change something it will effect our time in terms of finding. + How can we obey this principle? + -In the example,2 different job should be done in the 2 different class. + + diff --git a/SolidPrinciples/Lab_2_OpenClosedPrinciple/BadExample/CoffeeType.cs b/SolidPrinciples/Lab_2_OpenClosedPrinciple/BadExample/CoffeeType.cs new file mode 100644 index 0000000..49735ad --- /dev/null +++ b/SolidPrinciples/Lab_2_OpenClosedPrinciple/BadExample/CoffeeType.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_2_OpenClosedPrinciple.BadExample +{ + public enum CoffeeType + { + Latte,Espresso,Machiato + } + public class BadCoffee + { + public double GetTotalPrice(double amount,CoffeeType coffeeType) + { + double totalPrice = 0; + if (coffeeType==CoffeeType.Espresso) + { + totalPrice += amount * 4.50; + + } + else if (coffeeType==CoffeeType.Latte) + { + totalPrice += amount * 4.50; + + } + else if (coffeeType==CoffeeType.Machiato) + { + totalPrice += amount * 6.75; + } + return totalPrice; + } + } +} diff --git a/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Abstract/GoodCar.cs b/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Abstract/GoodCar.cs new file mode 100644 index 0000000..cfdded8 --- /dev/null +++ b/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Abstract/GoodCar.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_2_OpenClosedPrinciple.GoodExample +{ + public abstract class GoodCar + { + public abstract double GetTotalPrice(double amount); + + } +} diff --git a/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Concrete/Door.cs b/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Concrete/Door.cs new file mode 100644 index 0000000..bb2ba4a --- /dev/null +++ b/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Concrete/Door.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_2_OpenClosedPrinciple.GoodExample.Concrete +{ + public class Door : GoodCar + { + public override double GetTotalPrice(double amount) + { + return amount*5.21; + } + } +} diff --git a/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Concrete/Gear.cs b/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Concrete/Gear.cs new file mode 100644 index 0000000..0a4e63d --- /dev/null +++ b/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Concrete/Gear.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_2_OpenClosedPrinciple.GoodExample.Concrete +{ + public class Gear:GoodCar + { + public override double GetTotalPrice(double amount) + { + return amount*68.75; + } + } +} diff --git a/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Concrete/Whell.cs b/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Concrete/Whell.cs new file mode 100644 index 0000000..fb76a76 --- /dev/null +++ b/SolidPrinciples/Lab_2_OpenClosedPrinciple/GoodExample/Concrete/Whell.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_2_OpenClosedPrinciple.GoodExample.Concrete +{ + public class Whell : GoodCar + { + public override double GetTotalPrice(double amount) + { + return amount * 7.99; + } + } +} diff --git a/SolidPrinciples/Lab_2_OpenClosedPrinciple/Theorical.txt b/SolidPrinciples/Lab_2_OpenClosedPrinciple/Theorical.txt new file mode 100644 index 0000000..e471ba6 --- /dev/null +++ b/SolidPrinciples/Lab_2_OpenClosedPrinciple/Theorical.txt @@ -0,0 +1,10 @@ +Open/Closed Principle + +Entities should close to changeable but it can be develop or extend.All classes that we want to create our other demand is creating extendable class.Also OOP support to extend every classes.But on this extend process creating classes should be design as a class doesnt need to modification.Basically,we don't change method and behaviour of this class but we can change class. + +In the example; +While a developer wants to update for library and framework ,that demands of the others for this changed codes developer easily reach to his codes and these codes can be changeable,by this way, he doesn't need to write all again. +Attention point is while we are adding a new special property for any method we doesn't change our methods that we created before. + +At this Lab,think a basic coffeshop app.In this app we should have coffee class and species of coffe class and also we should get enum class that to use coffee and species class informations.For every coffee species that we need to add,we are going to enum.At this point,as a result of extending,we have to change for two classes and then we are opposite of OCP.But if we create an abstract class that contained a method and then we should use override.By this way,we don't chane anyhing on the classes. + diff --git a/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/BadExample/BadAreaCalculator.cs b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/BadExample/BadAreaCalculator.cs new file mode 100644 index 0000000..ca3448d --- /dev/null +++ b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/BadExample/BadAreaCalculator.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_3_Liskov_s_Substituion_Pinciple.BadExample +{ + public class BadAreaCalculator + { + public static double CalculateArea(BadRectangle badRectangle) + { + return badRectangle.Height * badRectangle.Width; + + } + + public static double CalculateAre(BadSquare badSquare) + { + + // + return badSquare.Height * badSquare * Withd; + + } + } +} diff --git a/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/BadExample/BadRectangle.cs b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/BadExample/BadRectangle.cs new file mode 100644 index 0000000..0852118 --- /dev/null +++ b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/BadExample/BadRectangle.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_3_Liskov_s_Substituion_Pinciple.BadExample +{ + + //This is parent class + public class BadRectangle + { + + //on the bad example,parent class is BadRectangle class and members of BadRactengle assigned virtual + public virtual int Height { get; set; } + public virtual int Width { get; set; } + } +} diff --git a/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/BadExample/BadSquare.cs b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/BadExample/BadSquare.cs new file mode 100644 index 0000000..bf86754 --- /dev/null +++ b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/BadExample/BadSquare.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_3_Liskov_s_Substituion_Pinciple.BadExample +{ + public class BadSquare:BadRectangle + { + + // + int _height; + int _widht; + + public override int Height { get =>_height + ; set => _height = value; } + + public override int Width { get => _widht + ; set => _widht = value; } + } +} diff --git a/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/GoodExample/Abstract/Shape.cs b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/GoodExample/Abstract/Shape.cs new file mode 100644 index 0000000..8db8803 --- /dev/null +++ b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/GoodExample/Abstract/Shape.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_3_Liskov_s_Substituion_Pinciple.GoodExample.Abstract +{ + public abstract class Shape + { + //For this principle ,avoid of parent class aim failure, + + public int Id { get; set; } + public int Edge { get; set; } + + } +} diff --git a/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/GoodExample/Concrete/Rectangle.cs b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/GoodExample/Concrete/Rectangle.cs new file mode 100644 index 0000000..32589c9 --- /dev/null +++ b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/GoodExample/Concrete/Rectangle.cs @@ -0,0 +1,16 @@ +using SolidPrinciples.Lab_3_Liskov_s_Substituion_Pinciple.GoodExample.Abstract; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_3_Liskov_s_Substituion_Pinciple.GoodExample.Concrete +{ + public class Rectangle:Shape + { + public int width { get; set; } + public double RectangleArea() { return width * Edge; } + + } +} diff --git a/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/GoodExample/Concrete/Square.cs b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/GoodExample/Concrete/Square.cs new file mode 100644 index 0000000..511d8b3 --- /dev/null +++ b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/GoodExample/Concrete/Square.cs @@ -0,0 +1,17 @@ +using SolidPrinciples.Lab_3_Liskov_s_Substituion_Pinciple.GoodExample.Abstract; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_3_Liskov_s_Substituion_Pinciple.GoodExample.Concrete +{ + public class Square:Shape + { + public double SquareArea() + { + return Edge * Edge; + } + } +} diff --git a/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/Theorical.txt b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/Theorical.txt new file mode 100644 index 0000000..bc99a4e --- /dev/null +++ b/SolidPrinciples/Lab_3_LiskovsSubstituionPinciple/Theorical.txt @@ -0,0 +1,4 @@ +Liskov Substition Principle + +In this principle,"overrided or child classes,major or parent classes can change places."By this Rule,parent class which inherited to child class and without unexpected behaviour it should be use as a parent class. +Classic example of this principle is,think a rectangle.Height is every value.Square is a rectangle that has same extend and height.By the way, rectangle provide us to extend as a square.For this principle,we should change rectangle class as a child class,square class is a parent class.We should create a parent class which contains all mutual properties.Then we create a class for all geometric shape. \ No newline at end of file diff --git a/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/BadExample/Concrete/Dolphin.cs b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/BadExample/Concrete/Dolphin.cs new file mode 100644 index 0000000..c04edae --- /dev/null +++ b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/BadExample/Concrete/Dolphin.cs @@ -0,0 +1,24 @@ +using SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.BadExample.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.BadExample.Concrete +{ + public class Dolphin : ISeaAnimal + + //Dolphin.cs is inherited by ISeaAnimal with this way Dolphin took Walking method it is wrongly approach. + { + public string Swim() + { + return " All Dolphin can swim"; + } + + public string Walk() + { + return " All Dolphin can not walk"; + } + } +} diff --git a/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/BadExample/Concrete/Penguin.cs b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/BadExample/Concrete/Penguin.cs new file mode 100644 index 0000000..a0342ba --- /dev/null +++ b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/BadExample/Concrete/Penguin.cs @@ -0,0 +1,22 @@ +using SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.BadExample.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.BadExample.Concrete +{ + public class Penguin : ISeaAnimal + { + public string Swim() + { + return "All Penguin can swim"; + } + + public string Walk() + { + return "All Penguin can walk" ; + } + } +} diff --git a/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/BadExample/Interfaces/ISeaAnimal.cs b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/BadExample/Interfaces/ISeaAnimal.cs new file mode 100644 index 0000000..1bc220e --- /dev/null +++ b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/BadExample/Interfaces/ISeaAnimal.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.BadExample.Interfaces +{ + public interface ISeaAnimal + { + string Swim(); + + string Walk(); + + } +} diff --git a/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Concrete/Dolphin.cs b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Concrete/Dolphin.cs new file mode 100644 index 0000000..60167df --- /dev/null +++ b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Concrete/Dolphin.cs @@ -0,0 +1,17 @@ +using SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.GoodExample.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.GoodExample.Concrete +{ + public class Dolphin : IWalknessSeaAnimal + { + public string Swim() + { + return "All Dolphin can walk" ; + } + } +} diff --git a/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Concrete/Penguin.cs b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Concrete/Penguin.cs new file mode 100644 index 0000000..b20ecbe --- /dev/null +++ b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Concrete/Penguin.cs @@ -0,0 +1,22 @@ +using SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.GoodExample.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.GoodExample.Concrete +{ + public class Penguin : ISwimSeaAnimal,IWalkSeaAnimal + { + public string Swim() + { + return "All penguin swim"; + } + + public string Walk() + { + return "All penguin walk"; + } + } +} diff --git a/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Interfaces/ISwimSeaAnimal.cs b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Interfaces/ISwimSeaAnimal.cs new file mode 100644 index 0000000..40585dd --- /dev/null +++ b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Interfaces/ISwimSeaAnimal.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.GoodExample.Interfaces +{ + public interface ISwimSeaAnimal + { + string Swim(); + } +} diff --git a/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Interfaces/IWalkSeaAnimal.cs b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Interfaces/IWalkSeaAnimal.cs new file mode 100644 index 0000000..d22204e --- /dev/null +++ b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Interfaces/IWalkSeaAnimal.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.GoodExample.Interfaces +{ + public interface IWalkSeaAnimal + { + string Walk(); + + + } +} diff --git a/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Interfaces/IWalknessSeaAnimal.cs b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Interfaces/IWalknessSeaAnimal.cs new file mode 100644 index 0000000..1d4881b --- /dev/null +++ b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/GoodExample/Interfaces/IWalknessSeaAnimal.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SolidPrinciples.Lab_4_InterfaceSegregationPrinciple.GoodExample.Interfaces +{ + public interface IWalknessSeaAnimal + { + string Swim(); + + + } +} diff --git a/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/Theorical.txt b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/Theorical.txt new file mode 100644 index 0000000..b35e7b6 --- /dev/null +++ b/SolidPrinciples/Lab_4_InterfaceSegregationPrinciple/Theorical.txt @@ -0,0 +1,6 @@ +Interface Segration Principle + +In this principle , for every class we should use interface class properly.This is similiar SRP&LSP principles.For this "All concrete class should relation with it is own interface class".This principle's main purpose is avoid overloaded interfaces.We can choose lots of interface but all interface should have one responsibility(SRP). + +Bad Example,we demonstrate in this field, child classes implement from unneceserry interface.For example, +ISeaAnimal interface is created by us.In this interface contains swimming and walking ability.I will create IDolphin and IPenguin classes.But IDolping can not walk.That's why we can not use ISeaAnimal for both of them.We should create an interface which contains Walking Methods.Moreover,IDolphin can not be inherited interface which was created by us for IPenguin. \ No newline at end of file diff --git a/SolidPrinciples/Lab_5_DependencyInversionPrinciple/Theorical.txt b/SolidPrinciples/Lab_5_DependencyInversionPrinciple/Theorical.txt new file mode 100644 index 0000000..8e82ea2 --- /dev/null +++ b/SolidPrinciples/Lab_5_DependencyInversionPrinciple/Theorical.txt @@ -0,0 +1,5 @@ +Dependency Inversion Principle + +In this principle,high level moduls-classes,low level modul-classes should be connected.Modul and Classes should connected with abstract/interfaces.Details should connected with abstract/interfaces.In this field,i mean details refer to methods which is inclueded class how to work.Crucial Point of that principle is that a class which run don't connect with the other tools.In addition to that , a class which inherited an interface , it should have parameter which is signed on the interface. + +In this point , parent class should be connect with an interface then we can inherit the other child classes. Because if we want to change any property we can easily reach to interface then parent class. \ No newline at end of file diff --git a/SolidPrinciples/SolidPrinciples.csproj b/SolidPrinciples/SolidPrinciples.csproj index 25eebba..5f4d514 100644 --- a/SolidPrinciples/SolidPrinciples.csproj +++ b/SolidPrinciples/SolidPrinciples.csproj @@ -52,6 +52,29 @@ Form1.cs + + + + + + + + + + + + + + + + + + + + + + + @@ -76,5 +99,16 @@ + + + + + + + + + + + \ No newline at end of file